|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Slides\Connector\Auth\Concerns; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
|
6
|
|
|
use Slides\Connector\Auth\Facades\AuthService; |
|
7
|
|
|
use Illuminate\Auth\Passwords\PasswordBroker; |
|
8
|
|
|
use Illuminate\Foundation\Auth\ResetsPasswords as BaseResetsPassword; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Trait SendsPasswordResetEmails |
|
12
|
|
|
* |
|
13
|
|
|
* @package Slides\Connector\Auth\Concerns |
|
14
|
|
|
*/ |
|
15
|
|
|
trait ResetsPasswords |
|
16
|
|
|
{ |
|
17
|
|
|
use BaseResetsPassword; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Display the password reset view for the given token. |
|
21
|
|
|
* |
|
22
|
|
|
* If no token is present, display the link request form. |
|
23
|
|
|
* |
|
24
|
|
|
* @param string $token |
|
25
|
|
|
* @param string $email |
|
26
|
|
|
* |
|
27
|
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
|
28
|
|
|
*/ |
|
29
|
|
|
public function showResetForm(string $token, string $email) |
|
30
|
|
|
{ |
|
31
|
|
|
if(!$email = AuthService::validatePasswordResetToken($token, $email)) { |
|
|
|
|
|
|
32
|
|
|
throw new \Symfony\Component\HttpKernel\Exception\NotFoundHttpException(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
return view('auth.passwords.reset')->with( |
|
36
|
|
|
['token' => $token, 'email' => $email] |
|
37
|
|
|
); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Reset user's password |
|
42
|
|
|
* |
|
43
|
|
|
* @param Request $request |
|
44
|
|
|
* |
|
45
|
|
|
* @return \Illuminate\Http\RedirectResponse |
|
46
|
|
|
*/ |
|
47
|
|
|
public function reset(Request $request) |
|
48
|
|
|
{ |
|
49
|
|
|
$this->validate($request, $this->rules(), $this->validationErrorMessages()); |
|
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
if(AuthService::resetPassword( |
|
|
|
|
|
|
52
|
|
|
$request->input('token'), |
|
53
|
|
|
$email = $request->input('email'), |
|
54
|
|
|
$password = $request->input('password'), |
|
55
|
|
|
$request->input('password_confirmation') |
|
56
|
|
|
)) { |
|
57
|
|
|
if(AuthService::login($email, $password)) { |
|
|
|
|
|
|
58
|
|
|
return $this->sendResetResponse(PasswordBroker::PASSWORD_RESET); |
|
|
|
|
|
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
return $this->sendResetFailedResponse($request, PasswordBroker::INVALID_PASSWORD); |
|
63
|
|
|
} |
|
64
|
|
|
} |