From 919a470528f84c9102c39c9a0f3a38d654fba529 Mon Sep 17 00:00:00 2001 From: sidya82 Date: Wed, 18 Feb 2015 23:23:12 +0100 Subject: [PATCH] =?UTF-8?q?=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20SRC/app/Http/Controllers/LoginController.php=20=09modifi?= =?UTF-8?q?=C3=A9=C2=A0:=20=20=20=20=20=20=20=20=20SRC/app/Http/routes.php?= =?UTF-8?q?=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20=20SRC/config/?= =?UTF-8?q?auth.php=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20=20SRC?= =?UTF-8?q?/resources/views/auth/reset.blade.php=20=09modifi=C3=A9=C2=A0:?= =?UTF-8?q?=20=20=20=20=20=20=20=20=20SRC/resources/views/emails/password.?= =?UTF-8?q?blade.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SRC/app/Http/Controllers/LoginController.php | 33 +++++++++++++++++-- SRC/app/Http/routes.php | 8 +++++ SRC/config/auth.php | 2 +- SRC/resources/views/auth/reset.blade.php | 20 ++++------- SRC/resources/views/emails/password.blade.php | 2 +- 5 files changed, 47 insertions(+), 18 deletions(-) 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') -
+
-
Reset Password
+
Réinitialiser Mot de Passe
@if (count($errors) > 0)
- Whoops! There were some problems with your input.

+ Oouups! Il y a un problème.

    @foreach ($errors->all() as $error)
  • {{ $error }}
  • @@ -18,26 +18,20 @@
@endif -
+ -
- -
- -
-
- +
- +
@@ -46,7 +40,7 @@
diff --git a/SRC/resources/views/emails/password.blade.php b/SRC/resources/views/emails/password.blade.php index 2030539..656be7f 100755 --- a/SRC/resources/views/emails/password.blade.php +++ b/SRC/resources/views/emails/password.blade.php @@ -1 +1 @@ -Click here to reset your password: {{ url('password/reset/'.$token) }} +Cliquer ici pour réinitialiser votre mot de passe : {{ url('password/reset/'.$token) }}