本文整理匯總了PHP中App\Http\Controllers\Auth\Auth::guard方法的典型用法代碼示例。如果您正苦於以下問題:PHP Auth::guard方法的具體用法?PHP Auth::guard怎麽用?PHP Auth::guard使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類App\Http\Controllers\Auth\Auth
的用法示例。
在下文中一共展示了Auth::guard方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: register
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function register(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
return redirect(action('Auth\\AuthController@showRegistrationForm'))->withErrors($validator)->withInput();
}
\Auth::guard($this->getGuard())->login($this->create($request->all()));
return redirect($this->redirectPath());
}
示例2: handleUserWasAuthenticated
/**
* Send the response after the user was authenticated.
*
* @param \Illuminate\Http\Request $request
* @param bool $throttles
* @return \Illuminate\Http\Response
*/
protected function handleUserWasAuthenticated(Request $request, $throttles)
{
if ($throttles) {
$this->clearLoginAttempts($request);
}
if (method_exists($this, 'authenticated')) {
return $this->authenticated($request, Auth::guard($this->getGuard())->user());
}
flash()->success('Welcome!', '');
return redirect()->intended($this->redirectPath());
}
示例3: register
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function register(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
$this->create($request->all());
if (!\Auth::user()) {
\Auth::guard($this->getGuard())->login($this->create($request->all()));
return redirect($this->redirectPath());
} else {
return redirect()->action('Auth\\UserController@getIndex')->with('message_type', 'success')->with('message', 'Successfully created! Edit them to add to groups!');
}
}
示例4: logout
/**
* Log the user out of the application.
*
* @return \Illuminate\Http\Response
*/
public function logout()
{
\Auth::guard($this->getGuard())->logout();
\Session::flash('message', 'You have been logged out.');
return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
}
示例5: resetPassword
/**
* Reset the given user's password.
*
* @param \Illuminate\Contracts\Auth\CanResetPassword $user
* @param string $password
* @return void
*/
protected function resetPassword($user, $password)
{
$user->password = $password;
$user->save();
Auth::guard($this->getGuard())->login($user);
}