Root/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | <?php class RemindersController extends Controller { /** * Display the password reminder view. * * @return Response */ public function getRemind() { return View::make( 'password.remind' ); } /** * Handle a POST request to remind a user of their password. * * @return Response */ public function postRemind() { //validate email entered here $rules = array ( 'email' => 'required|email' , ); $validator = Validator::make(Input::all(), $rules ); if ( $validator ->fails()) { return Redirect::to( 'password/remind' ) ->withErrors( $validator ) ->withInput(Input::except( 'password' )); } else { switch ( $response = Password::remind(Input::only( 'email' ))) { case Password::INVALID_USER: \Session::flash( 'message' , 'The email you entered does not exist. Try a different email.' ); return Redirect::back()->withInput(\Input::except( 'password' )); case Password::REMINDER_SENT: \Session::flash( 'message' , 'Please check your email for instructions on how to reset your password' ); return Redirect::to( 'password/remind' ); } } } /** * Display the password reset view for the given token. * * @param string $token * @return Response */ public function getReset( $token = null) { if ( is_null ( $token )) App::abort(404); return View::make( 'password.reset' )->with( 'token' , $token ); } /** * Handle a POST request to reset a user's password. * * @return Response */ public function postReset() { //validate input here $rules = array ( 'email' => 'required|email' , 'password' => 'required|confirmed' , 'token' => 'required' , ); $validator = Validator::make(Input::all(), $rules ); if ( $validator ->fails()) { return Redirect::back() ->withErrors( $validator ) ->withInput(Input::except( 'password' , 'password_confirmation' )); } $credentials = Input::only( 'email' , 'password' , 'password_confirmation' , 'token' ); $response = Password::reset( $credentials , function ( $user , $password ) { $user ->password = Hash::make( $password ); $user ->save(); }); switch ( $response ) { case Password::INVALID_PASSWORD: case Password::INVALID_TOKEN: case Password::INVALID_USER: \Session::flash( 'message' , 'You have to enter the correct information to proceed' ); return Redirect::back()->with( 'error' , Lang::get( $response )); case Password::PASSWORD_RESET: \Session::flash( 'message' , 'You can now login with your new credentials.' ); return Redirect::to( 'login' ); } } } |