gq il y a 7 ans
Parent
commit
1ef2e6821d
1 fichiers modifiés avec 7 ajouts et 10 suppressions
  1. 7 10
      server/app/Http/Controllers/Api/V1/AuthController.php

+ 7 - 10
server/app/Http/Controllers/Api/V1/AuthController.php

xqd xqd xqd xqd xqd xqd
@@ -30,6 +30,7 @@ class AuthController extends Controller
      * @apiPermission none
      * @apiVersion 0.1.0
      * @apiParam {string}  phone    手机号码
+     * @apiParam {string}  [wechat]    微信openid
      * @apiParam {String}  verify_code  手机验证码
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
@@ -66,7 +67,7 @@ class AuthController extends Controller
      *    1610    SERVICE_CODE_FAILED          验证码错误
      *
      */
-    public function login(Request $request,$openid_webo=null,$type=null) {
+    public function login(Request $request) {
         $validator = Validator::make($request->all(),
             [
                 'phone'         => 'required|regex:/^1[34578]\d{9}$/',
@@ -83,6 +84,7 @@ class AuthController extends Controller
             return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
 
         $phone = $request->phone;
+        $wechat = $request->wechat;
         $key = $this->keySmsCode . $phone;
         $code = Cache::store('file')->get($key);
         $password = 123456;
@@ -96,13 +98,8 @@ class AuthController extends Controller
         if ($status == 0) return $this->error(ErrorCode::LOCK_USER);
         if (Auth::attempt(['phone'=>$phone,'password'=>$password])) {
             $user = Auth::user();
-            if (!empty($openid_webo)) {
-                if ($type == 'wechat') {
-                    $user->wechat =$openid_webo;
-                }
-                if ($type == 'webo') {
-                    $user->webo =$openid_webo;
-                }
+            if (!empty($wechat)) {
+                $user->wechat =$wechat;
                 $user->save();
             }
             \Log::info($user);
@@ -114,7 +111,7 @@ class AuthController extends Controller
     }
 
 
-//    第三方登录  微信、微博
+//    第三方登录  微信
     /**
      * @api {post} /api/auth/wechat_login 微信登陆(login)
      * @apiDescription 微信登陆(login)
@@ -160,7 +157,7 @@ class AuthController extends Controller
             return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
         $user = UserInfoModel::where('wechat',$request->wechat)->first();
         if (empty($user)) {
-           $this->login($request,$request->wechat,'wechat');
+           $this->login($request);
         }else{
             $token = $user->createToken($user->phone)->accessToken;
             return $this->api(compact( 'user', 'code','token'));