本文整理匯總了PHP中Illuminate\Auth\Passwords\PasswordBroker::getToken方法的典型用法代碼示例。如果您正苦於以下問題:PHP PasswordBroker::getToken方法的具體用法?PHP PasswordBroker::getToken怎麽用?PHP PasswordBroker::getToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Illuminate\Auth\Passwords\PasswordBroker
的用法示例。
在下文中一共展示了PasswordBroker::getToken方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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)]);
}
}