|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* NOTICE OF LICENSE |
|
5
|
|
|
* |
|
6
|
|
|
* Part of the Rinvex Fort Package. |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to The MIT License (MIT) |
|
9
|
|
|
* that is bundled with this package in the LICENSE file. |
|
10
|
|
|
* |
|
11
|
|
|
* Package: Rinvex Fort Package |
|
12
|
|
|
* License: The MIT License (MIT) |
|
13
|
|
|
* Link: https://rinvex.com |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
namespace Rinvex\Fort\Http\Controllers\Frontend; |
|
17
|
|
|
|
|
18
|
|
|
use Illuminate\Support\Facades\Lang; |
|
19
|
|
|
use Rinvex\Fort\Contracts\ResetBrokerContract; |
|
20
|
|
|
use Rinvex\Fort\Http\Requests\PasswordResetRequest; |
|
21
|
|
|
use Rinvex\Fort\Http\Controllers\AbstractController; |
|
22
|
|
|
|
|
23
|
|
|
class ForgotPasswordController extends AbstractController |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* Create a new reset password controller instance. |
|
27
|
|
|
* |
|
28
|
|
|
* @return void |
|
|
|
|
|
|
29
|
|
|
*/ |
|
30
|
|
|
public function __construct() |
|
31
|
|
|
{ |
|
32
|
|
|
$this->middleware($this->getGuestMiddleware(), ['except' => $this->middlewareWhitelist]); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Show the password reset request form. |
|
37
|
|
|
* |
|
38
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
|
|
39
|
|
|
*/ |
|
40
|
|
|
public function showForgotPassword() |
|
41
|
|
|
{ |
|
42
|
|
|
return view('rinvex.fort::password.forgot'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Process the password reset request form. |
|
47
|
|
|
* |
|
48
|
|
|
* @param \Rinvex\Fort\Http\Requests\PasswordResetRequest $request |
|
49
|
|
|
* |
|
50
|
|
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse |
|
51
|
|
|
*/ |
|
52
|
|
|
public function processForgotPassword(PasswordResetRequest $request) |
|
53
|
|
|
{ |
|
54
|
|
|
$result = app('rinvex.fort.resetter')->broker($this->getBroker())->sendResetLink($request->except(['_token'])); |
|
55
|
|
|
|
|
56
|
|
|
switch ($result) { |
|
57
|
|
|
case ResetBrokerContract::LINK_SENT: |
|
58
|
|
|
return intend([ |
|
59
|
|
|
'intended' => route('home'), |
|
60
|
|
|
'with' => ['rinvex.fort.alert.success' => Lang::get($result)], |
|
61
|
|
|
]); |
|
62
|
|
|
|
|
63
|
|
|
case ResetBrokerContract::INVALID_USER: |
|
64
|
|
|
default: |
|
65
|
|
|
return intend([ |
|
66
|
|
|
'back' => true, |
|
67
|
|
|
'withInput' => $request->only('email'), |
|
68
|
|
|
'withErrors' => ['email' => Lang::get($result)], |
|
69
|
|
|
]); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.