Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function login(Request $request)
- {
- $this->validateLogin($request);
- if ($this->hasTooManyLoginAttempts($request)) {
- $this->fireLockoutEvent($request);
- return $this->sendLockoutResponse($request);
- }
- if ($this->attemptLogin($request)) {
- $otp_secret = Redis::get('otp_user_' . \Auth::id());
- if($otp_secret){
- $request->session()->flash('otp_user', \Auth::id());
- \Auth::logout();
- $request->session()->regenerate();
- return \Response::json([
- 'success' => true,
- 'redirect' => route('otp')
- ]);
- }else{
- return \Response::json([
- 'success' => true,
- 'redirect' => route('home')
- ]);
- }
- }else{
- $user = User::fromLogin($request->get('login'));
- if($user && $user->old_password){
- if (strtolower($user->old_password) == strtolower(md5(md5($request->get('password'))))){
- $user->password = bcrypt($request->get('password'));
- $user->old_password = null;
- $user->save();
- \Auth::loginUsingId($user->id, true);
- return \Response::json([
- 'success' => true,
- 'redirect' => route('home')
- ]);
- }
- }
- }
- $this->incrementLoginAttempts($request);
- return $this->sendFailedLoginResponse($request);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement