예제 #1
0
 public function postRecoverPassword(PasswordRecoveryRequest $request)
 {
     $question = $request->get('question');
     $answer = $request->get('answer');
     $user = User::where('email', $request->get('email'))->first();
     if ($user->question === $question && Hash::check($answer, $user->answer)) {
         $user->password = bcrypt($request->get('password'));
         $user->save();
         return redirect('auth/login')->with(['success' => 'The password was changed']);
     }
     return redirect('auth/recover-password')->withInput($request->only('email', 'question'))->withErrors('The answer or the question doesn\'t match');
 }