Commit 032938a9 by 杨树贤

优化无密码登录

parent 70569f70
......@@ -27,7 +27,7 @@ class UserRegister extends FormRequest
public function rules()
{
return [
'password' => 'required',
//'password' => 'required',
//'salt' => 'required',
'mobile' => 'required_without:email',
'email' => 'required_without:mobile',
......
......@@ -19,7 +19,9 @@ class UserService
}
if (!$ucId) {
if (!empty($data['password'])) {
$data['password'] = PasswordService::passwordHash($data['password'],$data['salt']);
}
//去新增注册
$data['create_time'] = time();
$ucId = UserModel::insertGetId($data);
......@@ -53,8 +55,10 @@ class UserService
}
$salt = $exists->salt;
$passwordHash = '';
if ($data['password']) {
$passwordHash = PasswordService::passwordHash($data['password'], $salt);
}
$user = $loginQuery->select([
'uc_id',
'mobile',
......@@ -84,7 +88,7 @@ class UserService
//绑定手机
public static function bindMobile($ucId, $mobile)
{
//先去判断这个email是否已经被其它账号使用了
//先去判断这个手机号是否已经被其它账号使用了
$exists = UserModel::where('uc_id', '!=', $ucId)->where('mobile', $mobile)->exists();
if ($exists) {
throw new InvalidRequestException('该手机号已经被其它账户绑定了,请确认后重新提交');
......
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