|
|
|
@ -27,7 +27,7 @@ class User extends Model |
|
|
|
$password = $this->generateHashedPassword($data['password'], $salt); |
|
|
|
|
|
|
|
$this->save([ |
|
|
|
'username' => generate_random_str(), |
|
|
|
'avatar' => '', |
|
|
|
'password' => $password, |
|
|
|
'salt' => $salt, |
|
|
|
'phone' => $data['phone'], |
|
|
|
@ -41,7 +41,7 @@ class User extends Model |
|
|
|
/** |
|
|
|
* 用户登录 |
|
|
|
* @param $data |
|
|
|
* @return User|array|mixed|Model |
|
|
|
* @return array |
|
|
|
* @throws \think\db\exception\DataNotFoundException |
|
|
|
* @throws \think\db\exception\DbException |
|
|
|
* @throws \think\db\exception\ModelNotFoundException |
|
|
|
@ -51,7 +51,7 @@ class User extends Model |
|
|
|
public function login($data) |
|
|
|
{ |
|
|
|
// 根据用户名查询用户信息 |
|
|
|
$user = $this->where('phone', $data['phone'])->field('id,username,phone,invite_code,password,salt')->find(); |
|
|
|
$user = $this->where('phone', $data['phone'])->field('id,avatar,phone,invite_code,password,salt')->find(); |
|
|
|
|
|
|
|
if ($user) { |
|
|
|
// 使用相同的盐值对输入密码进行哈希验证 |
|
|
|
|