| @@ 10-78 (lines=69) @@ | ||
| 7 | use Illuminate\Foundation\Auth\ResetsPasswords; |
|
| 8 | use Illuminate\Http\Request; |
|
| 9 | ||
| 10 | class PasswordController extends Controller |
|
| 11 | { |
|
| 12 | use ResetsPasswords { |
|
| 13 | ResetsPasswords::reset as defaultReset; |
|
| 14 | } |
|
| 15 | ||
| 16 | /** @var string */ |
|
| 17 | protected $guard; |
|
| 18 | ||
| 19 | /** @var string */ |
|
| 20 | protected $broker; |
|
| 21 | ||
| 22 | /** @var string */ |
|
| 23 | protected $linkRequestView; |
|
| 24 | ||
| 25 | /** @var string */ |
|
| 26 | protected $resetView; |
|
| 27 | ||
| 28 | /** @var string */ |
|
| 29 | protected $subject; |
|
| 30 | ||
| 31 | public function __construct() |
|
| 32 | { |
|
| 33 | $this->guard = 'back'; |
|
| 34 | $this->broker = 'back'; |
|
| 35 | $this->linkRequestView = 'back.auth.password'; |
|
| 36 | $this->resetView = 'back.auth.reset'; |
|
| 37 | $this->subject = fragment('passwords.subjectEmail').' '.config('app.url'); |
|
| 38 | } |
|
| 39 | ||
| 40 | public function redirectPath() |
|
| 41 | { |
|
| 42 | return action('Back\AuthController@getLogin'); |
|
| 43 | } |
|
| 44 | ||
| 45 | public function showResetForm(Request $request, $token = null) |
|
| 46 | { |
|
| 47 | if (empty($token)) { |
|
| 48 | return redirect()->action('Back\PasswordController@getEmail'); |
|
| 49 | } |
|
| 50 | ||
| 51 | $user = User::findByToken($token); |
|
| 52 | ||
| 53 | if (empty($user)) { |
|
| 54 | return redirect()->action('Back\PasswordController@getEmail'); |
|
| 55 | } |
|
| 56 | ||
| 57 | return view($this->resetView)->with(compact('user', 'token')); |
|
| 58 | } |
|
| 59 | ||
| 60 | public function reset(Request $request) |
|
| 61 | { |
|
| 62 | // We use min. 8 character passwords, so doing some extra validation here. |
|
| 63 | $this->validate($request, [ |
|
| 64 | 'password' => 'required|confirmed|min:8', |
|
| 65 | ]); |
|
| 66 | ||
| 67 | return $this->defaultReset($request); |
|
| 68 | } |
|
| 69 | ||
| 70 | protected function resetPassword($user, $password) |
|
| 71 | { |
|
| 72 | $user->password = $password; |
|
| 73 | ||
| 74 | $user->save(); |
|
| 75 | ||
| 76 | auth()->guard($this->getGuard())->login($user); |
|
| 77 | } |
|
| 78 | } |
|
| 79 | ||
| @@ 10-78 (lines=69) @@ | ||
| 7 | use Illuminate\Foundation\Auth\ResetsPasswords; |
|
| 8 | use Illuminate\Http\Request; |
|
| 9 | ||
| 10 | class PasswordController extends Controller |
|
| 11 | { |
|
| 12 | use ResetsPasswords { |
|
| 13 | ResetsPasswords::reset as defaultReset; |
|
| 14 | } |
|
| 15 | ||
| 16 | /** @var string */ |
|
| 17 | protected $guard; |
|
| 18 | ||
| 19 | /** @var string */ |
|
| 20 | protected $broker; |
|
| 21 | ||
| 22 | /** @var string */ |
|
| 23 | protected $linkRequestView; |
|
| 24 | ||
| 25 | /** @var string */ |
|
| 26 | protected $resetView; |
|
| 27 | ||
| 28 | /** @var string */ |
|
| 29 | protected $subject; |
|
| 30 | ||
| 31 | public function __construct() |
|
| 32 | { |
|
| 33 | $this->guard = 'front'; |
|
| 34 | $this->broker = 'front'; |
|
| 35 | $this->linkRequestView = 'front.auth.password'; |
|
| 36 | $this->resetView = 'front.auth.reset'; |
|
| 37 | $this->subject = fragment('passwords.subjectEmail').' '.config('app.url'); |
|
| 38 | } |
|
| 39 | ||
| 40 | public function redirectPath() |
|
| 41 | { |
|
| 42 | return action('Front\AuthController@getLogin'); |
|
| 43 | } |
|
| 44 | ||
| 45 | public function showResetForm(Request $request, $token = null) |
|
| 46 | { |
|
| 47 | if (empty($token)) { |
|
| 48 | return redirect()->action('Front\PasswordController@getEmail'); |
|
| 49 | } |
|
| 50 | ||
| 51 | $user = User::findByToken($token); |
|
| 52 | ||
| 53 | if (empty($user)) { |
|
| 54 | return redirect()->action('Front\PasswordController@getEmail'); |
|
| 55 | } |
|
| 56 | ||
| 57 | return view($this->resetView)->with(compact('user', 'token')); |
|
| 58 | } |
|
| 59 | ||
| 60 | public function reset(Request $request) |
|
| 61 | { |
|
| 62 | // We use min. 8 character passwords, so doing some extra validation here. |
|
| 63 | $this->validate($request, [ |
|
| 64 | 'password' => 'required|confirmed|min:8', |
|
| 65 | ]); |
|
| 66 | ||
| 67 | return $this->defaultReset($request); |
|
| 68 | } |
|
| 69 | ||
| 70 | protected function resetPassword($user, $password) |
|
| 71 | { |
|
| 72 | $user->password = $password; |
|
| 73 | ||
| 74 | $user->save(); |
|
| 75 | ||
| 76 | auth()->guard($this->getGuard())->login($user); |
|
| 77 | } |
|
| 78 | } |
|
| 79 | ||