|
@@ -218,62 +218,6 @@ class AuthController extends Controller
|
|
]);
|
|
]);
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * @api {post} /api/auth/password 设置密码(password)
|
|
|
|
- * @apiDescription 上传头像(password)
|
|
|
|
- * @apiGroup Auth
|
|
|
|
- * @apiPermission Passport
|
|
|
|
- * @apiVersion 0.1.0
|
|
|
|
- * @apiParam {String} password 密码
|
|
|
|
- * @apiSuccessExample {json} Success-Response:
|
|
|
|
- * HTTP/1.1 200 OK
|
|
|
|
- * {
|
|
|
|
- * "state": true,
|
|
|
|
- * "code": 0,
|
|
|
|
- * "message": "",
|
|
|
|
- * "data": {
|
|
|
|
- * "result": true,
|
|
|
|
- * }
|
|
|
|
- * }
|
|
|
|
- * @apiErrorExample {json} Error-Response:
|
|
|
|
- * HTTP/1.1 400 Bad Request
|
|
|
|
- * {
|
|
|
|
- * "state": false,
|
|
|
|
- * "code": 1000,
|
|
|
|
- * "message": "传入参数不正确",
|
|
|
|
- * "data": null or []
|
|
|
|
- * }
|
|
|
|
- * 可能出现的错误代码:
|
|
|
|
- * 200 SAVE_USER_FAILED 保存用户数据失败
|
|
|
|
- * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
|
- */
|
|
|
|
- public function setPassword(Request $request) {
|
|
|
|
- $validator = Validator::make($request->input(),
|
|
|
|
- [
|
|
|
|
- 'password' => 'required|between:6,16',
|
|
|
|
- ],
|
|
|
|
- [
|
|
|
|
- 'password.required' => '请输入密码',
|
|
|
|
- 'password.between' => '密码长度6~16位',
|
|
|
|
- ]
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- if ($validator->fails()) {
|
|
|
|
- return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $pass = $request->get('password');
|
|
|
|
-
|
|
|
|
- $user = Auth::user();
|
|
|
|
- $user->password = bcrypt($pass);
|
|
|
|
- if (!$user->save()) {
|
|
|
|
- return $this->error(ErrorCode::SAVE_USER_FAILED);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return $this->api([
|
|
|
|
- 'result' => true,
|
|
|
|
- ]);
|
|
|
|
- }
|
|
|
|
|
|
|
|
public function isLogin()
|
|
public function isLogin()
|
|
{
|
|
{
|
|
@@ -285,99 +229,6 @@ class AuthController extends Controller
|
|
]);
|
|
]);
|
|
}
|
|
}
|
|
|
|
|
|
- public function check_password(Request $request)
|
|
|
|
- {
|
|
|
|
- $password = Auth::user()->password;
|
|
|
|
-
|
|
|
|
- if(!Hash::check($request->oldpassword,$password)) return $this->error(ErrorCode::CHECK_OLDPASSWORD_FAILED);
|
|
|
|
-
|
|
|
|
- return $this->api(null,0,'验证通过');
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * @api {post} /api/auth/reset 找回密码(reset)
|
|
|
|
- * @apiDescription 找回密码(reset)
|
|
|
|
- * @apiGroup Auth
|
|
|
|
- * @apiPermission none
|
|
|
|
- * @apiVersion 0.1.0
|
|
|
|
- * @apiParam {Phone} phone 手机
|
|
|
|
- * @apiParam {int} type 帐户类型:1.个人,2.商户
|
|
|
|
- * @apiParam {String} verify_code 手机验证码
|
|
|
|
- * @apiParam {String} password password
|
|
|
|
- * @apiSuccessExample {json} Success-Response:
|
|
|
|
- * HTTP/1.1 200 OK
|
|
|
|
- * {
|
|
|
|
- * "state": true,
|
|
|
|
- * "code": 0,
|
|
|
|
- * "message": "",
|
|
|
|
- * "data": {
|
|
|
|
- * "result": true,
|
|
|
|
- * }
|
|
|
|
- * }
|
|
|
|
- * @apiErrorExample {json} Error-Response:
|
|
|
|
- * HTTP/1.1 400 Bad Request
|
|
|
|
- * {
|
|
|
|
- * "state": false,
|
|
|
|
- * "code": 1000,
|
|
|
|
- * "message": "传入参数不正确",
|
|
|
|
- * "data": null or []
|
|
|
|
- * }
|
|
|
|
- * 可能出现的错误代码:
|
|
|
|
- * 200 SAVE_USER_FAILED 保存用户数据失败
|
|
|
|
- * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
|
- * 1101 INCORRECT_VERIFY_CODE 输入验证码错误
|
|
|
|
- * 1105 USER_DOES_NOT_EXIST 用户不存在
|
|
|
|
- */
|
|
|
|
- public function reset(Request $request) {
|
|
|
|
- $validator = Validator::make($request->all(),
|
|
|
|
- [
|
|
|
|
- 'phone' => 'required|regex:/^1[34578]\d{9}$/',
|
|
|
|
- 'verify_code' => 'required',
|
|
|
|
- 'password' => 'required|between:6,16',
|
|
|
|
- ],
|
|
|
|
- [
|
|
|
|
- 'phone.required' => '手机号码必填',
|
|
|
|
- 'phone.regex' => '手机号码格式不正确',
|
|
|
|
- 'verify_code.required' => '请输入校验码',
|
|
|
|
- 'password.required' => '请输入密码',
|
|
|
|
- 'password.between' => '密码长度6~16位',
|
|
|
|
- ]
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- if ($validator->fails()) {
|
|
|
|
- return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '', $validator->messages());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $phone = $request->get('phone');
|
|
|
|
- $verify_code = $request->get('verify_code');
|
|
|
|
- $pass = $request->get('password');
|
|
|
|
-
|
|
|
|
- $key = $this->keySmsCode . $phone;
|
|
|
|
-// if (Redis::exists($key)) {
|
|
|
|
- if (Cache::store('file')->has($key)) {
|
|
|
|
-// $code = Redis::get($key);
|
|
|
|
- $code = Cache::store('file')->get($key);
|
|
|
|
- if ($code == $verify_code) {
|
|
|
|
- $user = User::where([
|
|
|
|
- 'phone' => $phone,
|
|
|
|
- ])->first();
|
|
|
|
-
|
|
|
|
- if (!$user) {
|
|
|
|
- return $this->error(ErrorCode::USER_DOES_NOT_EXIST);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //$password = app('hash')->make($request->get('password'));
|
|
|
|
- $user->password = bcrypt($pass);
|
|
|
|
- if (!$user->save()) {
|
|
|
|
- return $this->error(ErrorCode::SAVE_USER_FAILED);
|
|
|
|
- }
|
|
|
|
- Cache::store('file')->forget($key);
|
|
|
|
-
|
|
|
|
- return $this->api(['result' => true]);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return $this->error(ErrorCode::INCORRECT_VERIFY_CODE);
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|