當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PasswordBroker::getToken方法代碼示例

本文整理匯總了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)]);
     }
 }
開發者ID:ChenPeiyuan,項目名稱:student-infomation-manager,代碼行數:33,代碼來源:ChangePasswordController.php


注:本文中的Illuminate\Auth\Passwords\PasswordBroker::getToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。