Commit 70569f70 by 杨树贤

修复盐的问题

parent 7220ba08
Showing with 8 additions and 5 deletions
......@@ -19,6 +19,7 @@ class UserService
}
if (!$ucId) {
$data['password'] = PasswordService::passwordHash($data['password'],$data['salt']);
//去新增注册
$data['create_time'] = time();
$ucId = UserModel::insertGetId($data);
......@@ -41,15 +42,18 @@ class UserService
{
$loginQuery = UserModel::where('status', UserModel::STATUS_ENABLE);
if (!empty($data['mobile'])) {
$salt = UserModel::where('mobile', $data['mobile'])->value('salt');
$exists = UserModel::where('mobile', $data['mobile'])->first();
$loginQuery->where('mobile', $data['mobile']);
} else {
$salt = UserModel::where('email', $data['email'])->value('salt');
$exists = UserModel::where('email', $data['email'])->first();
$loginQuery->where('email', $data['email']);
}
if (empty($salt)) {
if (empty($exists)) {
throw new InvalidRequestException('该账号不存在');
}
$salt = $exists->salt;
$passwordHash = PasswordService::passwordHash($data['password'], $salt);
$user = $loginQuery->select([
'uc_id',
......@@ -57,10 +61,9 @@ class UserService
'email',
'create_time',
])->where('password', $passwordHash)->first();
UserModel::where('uc_id', $user['uc_id'])->update(['last_login_time' => time()]);
return $user ?: [];
return $user ? $user->toArray() : [];
}
//绑定邮箱
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment