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