|
1
|
|
|
<?php |
|
2
|
|
|
namespace Serverfireteam\Panel; |
|
3
|
|
|
|
|
4
|
|
|
use Illuminate\Contracts\Auth\PasswordBroker as PasswordBrokerContract; |
|
5
|
|
|
use Illuminate\Routing\Controller; |
|
6
|
|
|
use Illuminate\Support\Facades\Input; |
|
7
|
|
|
|
|
8
|
|
|
/******* |
|
9
|
|
|
* The RemindersControler handle the users Password reminding activities |
|
10
|
|
|
* |
|
11
|
|
|
*******/ |
|
12
|
|
|
class RemindersController extends Controller { |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Display the password reminder view. |
|
17
|
|
|
* |
|
18
|
|
|
* @return Response |
|
19
|
|
|
*/ |
|
20
|
|
|
public function getRemind() |
|
21
|
|
|
{ |
|
22
|
|
|
if (\Session::has('message')) { |
|
23
|
|
|
$message = \Session::get('message'); |
|
24
|
|
|
} else { |
|
25
|
|
|
$message = \Lang::get('panel::fields.enterEmail'); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
return \View::make('panelViews::passwordReminder') |
|
29
|
|
|
->with('message', $message) |
|
30
|
|
|
->with('mesType', \Session::get('mesType')); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Handle a POST request to remind a user of their password. |
|
35
|
|
|
* |
|
36
|
|
|
* @return Response |
|
37
|
|
|
*/ |
|
38
|
|
|
public function postRemind() |
|
39
|
|
|
{ |
|
40
|
|
|
\App::make('route'); |
|
41
|
|
|
|
|
42
|
|
|
\Config::set('auth.defaults.passwords', 'panel'); |
|
43
|
|
|
|
|
44
|
|
|
$response = \Password::sendResetLink(Input::only('email'), function($message) { |
|
45
|
|
|
$message->subject('Password Reminder'); |
|
46
|
|
|
}); |
|
47
|
|
|
|
|
48
|
|
|
switch ($response) { |
|
49
|
|
|
case PasswordBrokerContract::INVALID_USER: |
|
50
|
|
|
return \Redirect::back()->with('message', \Lang::get($response))->with('mesType', 'error'); |
|
51
|
|
|
|
|
52
|
|
|
case PasswordBrokerContract::RESET_LINK_SENT: |
|
53
|
|
|
return \Redirect::back()->with('message', \Lang::get($response))->with('mesType', 'info'); |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Display the password reset view for the given token. |
|
59
|
|
|
* |
|
60
|
|
|
* @param string $token |
|
61
|
|
|
* @return Response |
|
62
|
|
|
*/ |
|
63
|
|
|
public function getReset($token = null) |
|
|
|
|
|
|
64
|
|
|
{ |
|
65
|
|
|
return \View::make('panelViews::passwordReset'); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function postReset() |
|
69
|
|
|
{ |
|
70
|
|
|
|
|
71
|
|
|
$credentials = Input::only( |
|
72
|
|
|
'email', 'password', 'password_confirmation', 'token' |
|
|
|
|
|
|
73
|
|
|
); |
|
74
|
|
|
\Config::set('auth.defaults.passwords', 'panel'); |
|
75
|
|
|
|
|
76
|
|
|
$response = \Password::reset($credentials, function($user, $password) { |
|
77
|
|
|
$user->password = \Hash::make($password); |
|
78
|
|
|
$user->save(); |
|
79
|
|
|
}); |
|
80
|
|
|
|
|
81
|
|
|
switch ($response) { |
|
82
|
|
|
case PasswordBrokerContract::INVALID_PASSWORD: |
|
83
|
|
|
return \Redirect::back()->with('message', \Lang::get($response))->with('mesType','error'); |
|
84
|
|
|
case PasswordBrokerContract::INVALID_TOKEN: |
|
85
|
|
|
return \Redirect::back()->with('message', \Lang::get($response))->with('mesType','error'); |
|
86
|
|
|
case PasswordBrokerContract::INVALID_USER: |
|
87
|
|
|
return \Redirect::back()->with('message', \Lang::get($response))->with('mesType','error'); |
|
88
|
|
|
case PasswordBrokerContract::PASSWORD_RESET: |
|
89
|
|
|
return \Redirect::to('/panel')->with('message', \Lang::get('panel::fields.successfullReset'))->with('mesType','info'); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/******** |
|
94
|
|
|
* The function displays the password |
|
95
|
|
|
* change view |
|
96
|
|
|
********/ |
|
97
|
|
|
public function getChangePassword() { |
|
98
|
|
|
|
|
99
|
|
|
$demo = false; |
|
100
|
|
|
if (\Config::get('panel.demo') == true) { |
|
101
|
|
|
$demo = true; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
return \View::make('panelViews::passwordChange')->with('demo_status', $demo); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/******** |
|
108
|
|
|
* After User enter the new password |
|
109
|
|
|
* this function handles the resetting the |
|
110
|
|
|
* the password |
|
111
|
|
|
********/ |
|
112
|
|
|
public function postChangePassword() { |
|
113
|
|
|
|
|
114
|
|
|
$user = Admin::find(\Auth::guard('panel')->user()->id); |
|
115
|
|
|
$password = Input::only('current_password'); |
|
116
|
|
|
$new_password = Input::only('password'); |
|
117
|
|
|
$retype_password = Input::only('password_confirmation'); |
|
118
|
|
|
$user_password = \Auth::guard('panel')->user()->password; |
|
119
|
|
|
|
|
120
|
|
|
//Check to see if user enters current password correctly |
|
121
|
|
|
if (\Hash::check($password['current_password'], $user_password)) { |
|
122
|
|
|
if ($new_password['password'] == $retype_password['password_confirmation']) { |
|
123
|
|
|
$user->password = \Hash::make($new_password['password']); |
|
124
|
|
|
$user->save(); |
|
125
|
|
|
return \Redirect::to('/panel/changePassword')->with('message', 'Successfully Changed Your Password!!'); |
|
126
|
|
|
} else { |
|
127
|
|
|
return \Redirect::to('/panel/changePassword') |
|
128
|
|
|
->with('message', 'Passwords not matched!!') |
|
129
|
|
|
->with('mesType', 'error'); |
|
130
|
|
|
} |
|
131
|
|
|
} else { |
|
132
|
|
|
return \Redirect::to('/panel/changePassword') |
|
133
|
|
|
->with('message', 'Password is not correct!!') |
|
134
|
|
|
->with('mesType', 'error'); |
|
135
|
|
|
} |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.