xiaogang 4 سال پیش
والد
کامیت
e24971d043
2فایلهای تغییر یافته به همراه36 افزوده شده و 26 حذف شده
  1. 30 26
      app/Http/Controllers/Api/AuthorizationsController.php
  2. 6 0
      app/Http/Controllers/Api/UserController.php

+ 30 - 26
app/Http/Controllers/Api/AuthorizationsController.php

xqd xqd xqd xqd xqd
@@ -12,6 +12,7 @@ use App\Services\SmsService;
 use App\Services\TencentImAccountService;
 use App\Transformers\UserTransformer;
 use Carbon\Carbon;
+use http\Env\Response;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Auth;
 use Illuminate\Support\Facades\DB;
@@ -80,7 +81,7 @@ class AuthorizationsController extends Controller
             return $this->response->errorForbidden($e->getMessage());
         }
 
-        return $res;
+        return response()->json($res);
     }
 
     /**
@@ -107,7 +108,7 @@ class AuthorizationsController extends Controller
             return $this->response->errorForbidden($exception->getMessage());
         }
 
-        return $res;
+        return response()->json($res);
     }
 
 
@@ -177,7 +178,7 @@ class AuthorizationsController extends Controller
        if(User::where(['ycode'=>$code])->first()){
            $code =  create_invite_code();
        }
-        return $code;
+       return $code;
     }
 
     /**
@@ -283,35 +284,38 @@ class AuthorizationsController extends Controller
      * 忘记密码
      */
     public function forget_password(Request $request){
-        $validator = Validator::make($request->all(), [
-            'mobile' => ['required', 'regex:/^1[3456789]\d{9}$/'],
-            'verifyKey' => 'bail|required|string',
-            'smsCode' => 'bail|required',
-            'password' => 'bail|required',
-        ],[
-            'mobile.required'=>"手机号码必须",
-            'mobile.regex'=>"手机号码格式错误",
-            'verifyKey.required'=>"验证码必须",
-            'smsCode.required'=>"短信验证码必须",
-            'password.required'=>"密码必须",
-        ]);
-        if ($validator->fails()) {
-            return $this->response()->errorForbidden($validator->messages()->first());
-        }
         try {
+            $validator = Validator::make($request->all(), [
+                'mobile' => ['required', 'regex:/^1[3456789]\d{9}$/'],
+                'verifyKey' => 'bail|required|string',
+                'smsCode' => 'bail|required',
+                'password' => 'bail|required',
+            ],[
+                'mobile.required'=>"手机号码必须",
+                'mobile.regex'=>"手机号码格式错误",
+                'verifyKey.required'=>"验证码必须",
+                'smsCode.required'=>"短信验证码必须",
+                'password.required'=>"密码必须",
+            ]);
+            if ($validator->fails()) {
+                throw new Exception($validator->messages()->first());
+            }
             //验证短信验证码
             SmsService::checkSmsCodeByVerifyKey($request->verifyKey, $request->smsCode);
+
+            $user = User::where(['mobile'=>$request->mobile])->first();
+            $user->password =$request->password;// Hash::make($request->password);
+            if(!$user->save()){
+                throw new Exception("设置失败");
+            }
+            $res = $this->do_login($request->mobile,$request->password);
+        }catch (\Exception $exception){
+            return $this->response->errorForbidden($exception->getMessage());
         } catch (SmsException $e) {
-            abort(403, $e->getMessage());
-        } catch (\Exception $e) {
-            abort(403, '短信校验失败');
+            return $this->response->errorForbidden($e->getMessage());
         }
+        return response()->json($res);
 
-        $user = User::where(['mobile'=>$request->mobile])->first();
-        $user->password =$request->password;// Hash::make($request->password);
-        if($user->save()){
-            return $this->response->noContent();
-        }
     }
 
     /**

+ 6 - 0
app/Http/Controllers/Api/UserController.php

xqd
@@ -445,6 +445,12 @@ class UserController extends Controller
         return response()->json(['message'=>'操作成功']);
     }
 
+    /**
+     * 设置手势锁
+     */
+    public function lock_pass(){
+
+    }
 
 
 }