本文整理汇总了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);
}