From f269d3c286332e78f00f83eceea407a82611c797 Mon Sep 17 00:00:00 2001 From: denisdulici Date: Wed, 3 Jan 2018 19:07:29 +0300 Subject: [PATCH] fixed #172 --- app/Http/Controllers/Auth/Reset.php | 23 ++++++++++++++++++++--- app/Models/Auth/User.php | 3 +-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Auth/Reset.php b/app/Http/Controllers/Auth/Reset.php index a4eb86e3a..5644dde85 100644 --- a/app/Http/Controllers/Auth/Reset.php +++ b/app/Http/Controllers/Auth/Reset.php @@ -3,10 +3,10 @@ namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; - use Illuminate\Foundation\Auth\ResetsPasswords; use Illuminate\Http\Request; use Illuminate\Support\Facades\Password; +use Illuminate\Support\Str; class Reset extends Controller { @@ -56,8 +56,8 @@ class Reset extends Controller // database. Otherwise we will parse the error and return the response. $response = $this->broker()->reset( $this->credentials($request), function ($user, $password) { - $this->resetPassword($user, $password); - } + $this->resetPassword($user, $password); + } ); // If the password was successfully reset, we will redirect the user back to @@ -68,6 +68,23 @@ class Reset extends Controller : $this->sendResetFailedResponse($request, $response); } + /** + * Reset the given user's password. + * + * @param \Illuminate\Contracts\Auth\CanResetPassword $user + * @param string $password + * @return void + */ + protected function resetPassword($user, $password) + { + $user->forceFill([ + 'password' => $password, + 'remember_token' => Str::random(60), + ])->save(); + + $this->guard()->login($user); + } + /** * Get the response for a successful password reset. * diff --git a/app/Models/Auth/User.php b/app/Models/Auth/User.php index e760f724d..b2a9f4db4 100644 --- a/app/Models/Auth/User.php +++ b/app/Models/Auth/User.php @@ -6,7 +6,6 @@ use App\Notifications\Auth\Reset; use Date; use EloquentFilter\Filterable; use GuzzleHttp\Exception\RequestException; -use Hash; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; @@ -126,7 +125,7 @@ class User extends Authenticatable */ public function setPasswordAttribute($value) { - $this->attributes['password'] = Hash::make($value); + $this->attributes['password'] = bcrypt($value); } /**