本文整理汇总了PHP中Illuminate\Auth\Passwords\PasswordBroker::reset方法的典型用法代码示例。如果您正苦于以下问题:PHP PasswordBroker::reset方法的具体用法?PHP PasswordBroker::reset怎么用?PHP PasswordBroker::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Auth\Passwords\PasswordBroker
的用法示例。
在下文中一共展示了PasswordBroker::reset方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postChange
/**
* Reset the given user's password.
*
* @param Request $request
* @return Response
*/
public function postChange(Request $request)
{
$validator = Validator::make($request->all(), ['token' => 'required', 'old_passwd' => 'required', 'password' => 'required|confirmed'], [], ['old_passwd' => '原密码', 'password' => '新密码']);
if ($validator->fails()) {
return Redirect::back()->withInput()->withErrors($validator);
}
$auth_array = array('email' => Auth::user()->email, 'password' => Input::get('old_passwd'));
if (Auth::validate($auth_array)) {
} else {
return redirect()->back()->withErrors("请输入正确的密码!");
}
$credentials = array('email' => Auth::user()->email, 'password' => Input::get('password'), 'password_confirmation' => Input::get('password_confirmation'), 'token' => Input::get('token'));
$response = $this->passwords->reset($credentials, function ($user, $password) {
$user->password = bcrypt($password);
$user->save();
$this->auth->login($user);
});
switch ($response) {
case PasswordBroker::PASSWORD_RESET:
$array = array('email' => Auth::user()->email);
$token = $this->passwords->getToken($array);
UserManageLog::insertLog("修改密码", Auth::user()->id, Auth::user()->name, Auth::user()->email, Auth::user()->name . '(' . Auth::user()->email . ')', null, null, $request->ip());
return view('auth.change_password')->withTips("密码修改成功!")->withToken($token);
default:
return redirect()->back()->withErrors(['email' => trans($response)]);
}
}
示例2: resetPassword
/**
* Process a password reset request. This is the last step in the reset process
*
* @param $credentials
* @return mixed|string
*/
public function resetPassword($credentials)
{
$status = $this->passwordBroker->reset($credentials, function ($user, $password) {
$user->password = app('hash')->make($password);
if ($user->save()) {
// auto login the user
auth()->login($user);
}
});
return $status;
}
示例3: postReset
public function postReset()
{
$credentials = $this->request->only('email', 'password', 'password_confirmation', 'token');
$response = $this->password->reset($credentials, function ($user, $password) {
$user->password = $this->hasher->make($password);
$user->save();
});
switch ($response) {
case $this->password->INVALID_PASSWORD:
case $this->password->INVALID_TOKEN:
case $this->password->INVALID_USER:
return $this->redirector->back()->with('error', $this->translator->get($response));
case $this->password->PASSWORD_RESET:
return $this->redirector->to('/');
}
}
示例4: postReset
/**
* Reset a users password
* @param AuthRequestInterface $request
* @param PasswordBroker $passwords
* @return Illuminate\Http\Response
*/
public function postReset(AuthRequestInterface $request, PasswordBroker $passwords)
{
$credentials = $request->only('email', 'password', 'password_confirmation', 'token');
$response = $passwords->reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
switch ($response) {
case PasswordBroker::PASSWORD_RESET:
return $this->passwordWasReset($request);
break;
default:
return $this->passwordWasNotReset($request, $response);
break;
}
}
示例5: reset
/**
* Reset the password for the given token.
*
* @param array $credentials
* @param \Closure $callback
* @return mixed
* @static
*/
public static function reset($credentials, $callback)
{
return \Illuminate\Auth\Passwords\PasswordBroker::reset($credentials, $callback);
}