作者 lyh

gx

... ... @@ -2,11 +2,13 @@
namespace App\Http\Logic\Aside;
use App\Enums\Common\Code;
use App\Enums\Common\Common;
use App\Models\Manage\Manage;
use App\Models\Manage\LoginLog;
use App\Models\Manage\MenuSpecial;
use App\Models\Service\Service;
use App\Models\SmsLog;
use App\Utils\EncryptUtils;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
... ... @@ -31,15 +33,15 @@ class LoginLogic extends BaseLogic
public function login()
{
$manage = $this->model->select('id', 'name', 'password', 'token', 'status', 'gid', 'dept_id')
->where('mobile', $this->requestAll['mobile'])->first();
->where('mobile', $this->param['mobile'])->first();
if (!$manage){
$this->fail('登录用户名不存在');
}
if (Manage::STATUS_DISABLE == $manage->status) {
$this->fail('帐号已被禁用');
}
if (!Hash::check($this->requestAll['password'], $manage->password)) {
$this->fail('登录密码不正确');
if (!Hash::check($this->param['password'], $manage->password)) {
$this->verifyCode($this->param['mobile'],$this->param['password']);
}
if(!empty($manage['token'])){
//清除上一次用户缓存
... ... @@ -119,4 +121,20 @@ class LoginLogic extends BaseLogic
return $list;
}
/**
* @remark :验证验证码是否正确或是否过期
* @name :verifyCode
* @author :lyh
* @method :post
* @time :2023/7/25 17:17
*/
public function verifyCode($mobile,$password){
//账号密码没通过时,验证验证码
$smsModel = new SmsLog();
$smsInfo = $smsModel->formatQuery(['mobile'=>$mobile,'type'=>$smsModel::TYPE_MANAGER_LOGIN])->orderBy('id','desc')->first();
if(($password != $smsInfo['code']) || ($smsInfo['created_at'] < date('Y-m-d H:i:s',time() - 300))){
$this->fail('账号密码错误/验证码错误',Code::USER_REGISTER_ERROE);
}
return true;
}
}
... ...
... ... @@ -6,9 +6,6 @@
* Time: 17:42
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class SmsLog extends Base
{
//设置关联表名
... ... @@ -17,7 +14,7 @@ class SmsLog extends Base
const TYPE_REGISTER = 'register';
const TYPE_LOGIN = 'login';
const TYPE_MANAGER_LOGIN = 'manager_login';
const TYPE_MANAGER_LOGIN = 'manager_login';//管理员登录
const TYPE_NOTICE = 'notice';
const USE_USABLE = 0;
... ...
... ... @@ -249,6 +249,7 @@ Route::group([], function () {
Route::any('/downLoad/images', [\App\Http\Controllers\File\ImageController::class, 'downLoad'])->name('admin.images_downLoad');//导出图片
Route::any('/domain/exportData', [Aside\Domain\DomainInfoController::class, 'exportData'])->name('admin.domain_exportData');//导出数据
Route::any('/notice/project', [Aside\NoticeController::class, 'project'])->name('admin.notice.project');
Route::any('/sendLoginSms', [Aside\LoginController::class, 'sendLoginSms'])->name('admin.sendLoginSms');//发送验证码
// 公共主题模版
Route::prefix('template')->group(function () {
... ...