黄宗昌 vor 2 Jahren
Ursprung
Commit
951fef4fc4
1 geänderte Dateien mit 9 neuen und 2 gelöschten Zeilen
  1. 9 2
      app/Http/Controllers/V1/AuthController.php

+ 9 - 2
app/Http/Controllers/V1/AuthController.php

xqd
@@ -80,17 +80,24 @@ class AuthController extends Controller
         $account = $request->input('account');
         $password = $request->input('password');
         $jpush_reg_id = $request->input('jpush_reg_id');
-        if (!$user = User::query()->where('account','=',$account)->first()) {
+        if (!$user = User::query()->where('account','=',$account)->orWhere('email','=',$account)->first()) {
             return $this->error('账号不存在');
         }
         // 账号是否禁用
 //        if($user->status == 0){
 //            return $this->error('账号已被禁用!');
 //        }
+//        $credentials1 = ['account' => $account, 'password' => $password];
+//        if (!auth('api')->attempt($credentials1)) {
+//            return $this->error('密码错误!');
+//        }
+
         $credentials1 = ['account' => $account, 'password' => $password];
-        if (!auth('api')->attempt($credentials1)) {
+        $credentials2 = ['email' => $account, 'password' => $password];
+        if (!auth('api')->attempt($credentials1) && !auth('api')->attempt($credentials2)) {
             return $this->error('密码错误!');
         }
+
         $data = $this->doLogin($user, $jpush_reg_id);
         return $this->success($data);
     }