diff --git a/SRC/app/Http/Controllers/LoginController.php b/SRC/app/Http/Controllers/LoginController.php index c4e8321..ce17f80 100755 --- a/SRC/app/Http/Controllers/LoginController.php +++ b/SRC/app/Http/Controllers/LoginController.php @@ -3,8 +3,9 @@ use Auth; use Input; use Validator; use Password; -use DB; - +use View; +use Redirect; +use Hash; class LoginController extends Controller { /** @@ -68,7 +69,7 @@ class LoginController extends Controller { public function initPassword() { - switch ($response = Password::sendResetLink(Input::only('email'))) + switch ($response = Password:: sendResetLink(Input::only('email'))) { case Password::INVALID_USER: return redirect('forgotten')->withErrors("Mail Invalide !")->withInput(); @@ -77,4 +78,30 @@ class LoginController extends Controller { } } + public function reset($token) + { + return View::make('auth.reset')->with('token', $token); + } + + public function update($token) + { + $credentials = array('token' => Input::get('token'), 'password' => Input::get('password'), 'password_confirmation' => Input::get('password_confirmation')); + $response = Password::reset($credentials, function($user, $password) + { + $user->password = Hash::make($password); + $user->save(); + }); + + switch ($response) + { + case Password::INVALID_PASSWORD: + return Redirect::back()->withErrors("Mot de passe non valide")->withInput(); + case Password::INVALID_TOKEN: + return Redirect::back()->withErrors("Clé invalide")->withInput(); + case Password::INVALID_USER: + return Redirect::back()->withErrors("Utilsateur invalide")->withInput(); + case Password::PASSWORD_RESET: + return Redirect::to('/login'); + } + } diff --git a/SRC/app/Http/routes.php b/SRC/app/Http/routes.php index 995f90a..effc392 100755 --- a/SRC/app/Http/routes.php +++ b/SRC/app/Http/routes.php @@ -14,6 +14,14 @@ Route::get('/', 'GameController@index'); Route::get('referents/{id}/games', 'GameController@showReferentGames')->where('id', '^((?!login|referent|admin).)*$'); Route::get('referents/{id}/games/{idGame}', 'GameController@showOneReferentGame'); +Route::get('password/reset/{token}', array( + 'uses' => 'LoginController@reset', + 'as' => 'password.reset' +)); +Route::post('password/reset/{token}', array( + 'uses' => 'LoginController@update', + 'as' => 'password.update' +)); Route::group(['middleware' => 'guest'], function () { diff --git a/SRC/config/auth.php b/SRC/config/auth.php index 5b436aa..7f52c0d 100755 --- a/SRC/config/auth.php +++ b/SRC/config/auth.php @@ -61,7 +61,7 @@ return [ 'password' => [ 'email' => 'emails.password', 'table' => 'password_resets', - 'expire' => 60, + 'expire' => 1440, ], ]; diff --git a/SRC/resources/views/auth/reset.blade.php b/SRC/resources/views/auth/reset.blade.php index 3ebd8de..4a15549 100755 --- a/SRC/resources/views/auth/reset.blade.php +++ b/SRC/resources/views/auth/reset.blade.php @@ -1,15 +1,15 @@ @extends('app') @section('content') -