Skip to content

Commit

Permalink
UserAuthService.php 修复因为隐藏password导致user模型 toarray之后无法获取password导致登录流…
Browse files Browse the repository at this point in the history
…程出错的问题
  • Loading branch information
ShaBaoFa committed Jul 5, 2024
1 parent 6dee2dd commit b11c510
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions app/System/Service/Dependencies/UserAuthService.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ public function login(UserServiceVo $userServiceVo): string
$mapper = container()->get(SystemUserMapper::class);
try {
event(new UserLoginBefore(['username' => $userServiceVo->getUsername(), 'password' => $userServiceVo->getPassword()]));
$userinfo = $mapper->checkUserByUsername($userServiceVo->getUsername())->toArray();
$password = $userinfo['password'];
unset($userinfo['password']);
$userLoginAfter = new UserLoginAfter($userinfo);
if ($mapper->checkPass($userServiceVo->getPassword(), $password)) {
/**
* @var SystemUser $userinfo
*/
$userinfo = $mapper->checkUserByUsername($userServiceVo->getUsername());
$userLoginAfter = new UserLoginAfter($userinfo->toArray());
if ($mapper->checkPass($userServiceVo->getPassword(), $userinfo->password)) {
if (
($userinfo['status'] == SystemUser::USER_NORMAL)
|| ($userinfo['status'] == SystemUser::USER_BAN && $userinfo['id'] == env('SUPER_ADMIN'))
($userinfo->status == SystemUser::USER_NORMAL)
|| ($userinfo->status == SystemUser::USER_BAN && $userinfo->getKeyName() == env('SUPER_ADMIN'))
) {
$userLoginAfter->message = t('jwt.login_success');
$token = user()->getToken($userLoginAfter->userinfo);
Expand Down

0 comments on commit b11c510

Please sign in to comment.