feat : basic
This commit is contained in:
@@ -13,7 +13,7 @@ namespace App\Service\Admin\Login;
|
||||
use App\Cache\Redis\Admin\UserCache;
|
||||
use App\Constants\Admin\UserCode;
|
||||
use App\Constants\AdminCode;
|
||||
use App\Exception\AdminException;
|
||||
use App\Exception\ErrException;
|
||||
use App\Extend\SystemUtil;
|
||||
use App\Lib\Crypto\CryptoFactory;
|
||||
use App\Model\AdminUser;
|
||||
@@ -59,19 +59,19 @@ class LoginService extends BaseService
|
||||
public function handle(): array
|
||||
{
|
||||
$userInfo = $this->adminUserModel->getAdminInfoByAccount($this->request->input('account'));
|
||||
if (!$userInfo) throw new AdminException('账号不存在');
|
||||
if (!$userInfo) throw new ErrException('账号不存在');
|
||||
|
||||
if ($userInfo->status == UserCode::DISABLE) throw new AdminException(UserCode::getMessage($userInfo->status),AdminCode::LOGIN_ERROR);
|
||||
if ($userInfo->status == UserCode::DISABLE) throw new ErrException(UserCode::getMessage($userInfo->status),AdminCode::LOGIN_ERROR);
|
||||
|
||||
// pass加密跟数据库做判断
|
||||
$password = $this->cryptoFactory->cryptoClass('admin-password',$this->request->input('password'),$userInfo->salt)->encrypt();
|
||||
if ($password != $userInfo->password) throw new AdminException('密码错误!');
|
||||
if ($password != $userInfo->password) throw new ErrException('密码错误!');
|
||||
|
||||
$userInfo->last_login_time = date('Y-m-d H:i:s');
|
||||
$userInfo->last_login_ip = SystemUtil::getClientIp();
|
||||
$userInfo->save();
|
||||
|
||||
if (!$userInfo->save()) throw new AdminException('登录失败');
|
||||
if (!$userInfo->save()) throw new ErrException('登录失败');
|
||||
|
||||
$cityId = $this->getCityById($userInfo->id);
|
||||
//生成 token
|
||||
|
||||
Reference in New Issue
Block a user