本文整理汇总了PHP中Illuminate\Contracts\Auth\Guard::logout方法的典型用法代码示例。如果您正苦于以下问题:PHP Guard::logout方法的具体用法?PHP Guard::logout怎么用?PHP Guard::logout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Auth\Guard
的用法示例。
在下文中一共展示了Guard::logout方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLogout
/**
* Log the user out of the application.
*
* @return \Illuminate\Http\Response
*/
public function getLogout()
{
$this->auth->logout();
return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/')->header('Cache-Control', 'nocache, no-store, max-age=0, must-revalidate');
//return redirect(\URL::previous());
//return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/')->header('Cache-Control', 'nocache, no-store, max-age=0, must-revalidate')->header('Pragma', 'no-cache')->header('Expires', 'Fri, 01 Jan 1990 00:00:00 GMT');
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->route('auth.signin');
}
} else {
$user = $this->auth->user();
if ($user->ban) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
$this->auth->logout();
notify()->flash('Banned', 'error', ['text' => $user->ban_reason]);
return redirect()->route('auth.signin');
}
}
}
/*$ipInfo = getIpInfo($request->getClientIp());
if($ipInfo){
if(isset($ipInfo['timezone'])){
if($ipInfo['timezone'] != $this->auth->user()->timezone){
$this->auth->user()->update([
'timezone' => $ipInfo['timezone']
]);
}
}
}*/
return $next($request);
}
示例3: handle
/**
* Handle
* @param User $user
* @throws UserNotActivatedException
*/
public function handle(User $user)
{
if ($user && !$user->isActivated()) {
$this->guard->logout();
throw new UserNotActivatedException();
}
}
示例4: handle
/**
* Handle
* @param User $user
*/
public function handle(User $user)
{
if ($user && $user->isBanned()) {
$this->guard->logout();
throw new UserIsBannedException('You are banned from the system');
}
}
示例5: getLogout
/**
* Log the user out of the application.
*
* @return \Illuminate\Http\Response
*/
public function getLogout()
{
Activity::log('Admin logt uit');
flash()->message(trans('auth.loggedOut'));
$this->auth->logout();
return redirect('/nl/auth/login');
}
示例6: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 403);
} else {
return redirect()->guest('auth/login');
}
}
if (!$request->user()->isAdmin() && $request->user()->cannot('dashboard_view')) {
$this->auth->logout();
return redirect()->guest('auth/login')->withErrors(trans('messages.permission_denied'));
}
$route_array = explode('.', $request->route()->getName());
$permission_name = array_search($route_array[2], array_dot($this->permission_fields));
if ($permission_name) {
$route_array[2] = explode('.', $permission_name)[0];
}
// $route_name = implode('_', $route_array);
$route_name = $route_array[1] . '_' . $route_array[2];
if (!$request->user()->isAdmin() && $request->user()->cannot($route_name)) {
//PATCH 为null
if ($request->ajax()) {
return response()->json(['status' => trans('messages.permission_denied'), 'type' => 'error', 'code' => 403]);
} else {
return view('errors.403');
}
}
return $next($request);
}
示例7: handle
public function handle($request, Closure $next)
{
$response = $next($request);
if ($this->auth->check()) {
$this->auth->logout();
}
return $response;
}
示例8: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->check() && $this->auth->user()->isBanned()) {
$this->auth->logout();
return ujs_redirect(route('users.disabled'));
}
return $next($request);
}
示例9: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$this->auth->user()->confirmed) {
$this->auth->logout();
return redirect()->guest('auth/login')->with('message', "Por favor confirma tu email");
}
return $next($request);
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->check()) {
$this->auth->logout();
return redirect()->back();
}
return $next($request);
}
示例11: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$this->auth->check() or $this->auth->user()->is_admin != 1) {
$this->auth->logout();
Session::flash('msg', 'Acesso restrito a administradores');
return redirect('/auth/login');
}
return $next($request);
}
示例12: logout
/**
* Log user out.
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function logout()
{
// Save user id to use later
$userId = $this->auth->user()->id;
// Log user out and fire event
$this->auth->logout();
event(new UserLoggedOut($userId));
return redirect(\URL::previous());
}
示例13: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->check()) {
if ($this->auth->user()->confirmed !== 1) {
$this->auth->logout();
return redirect('auth/login')->withErrors(['Mensaje Vinil-Shirt', 'Login Fallido, debes validar tu Email']);
}
}
return $next($request);
}
示例14: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$this->auth->user()->is_admin) {
$errors = new MessageBag();
$errors->add('adminarea', 'Restricted Area. Please use a admin login.');
$this->auth->logout();
return view('auth.login', compact('errors'));
}
return $next($request);
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// TODO: don't automatically log the user out some time after
// issue #29 is fixed or when disabled_at starts being used for
// something other than merged accounts.
if ($this->auth->check() && $this->auth->user()->disabled_at !== null && !($request->getMethod() === 'POST' && $request->getRequestUri() == '/auth/logout')) {
$this->auth->logout();
// return Response::view('home.account-disabled', ['username' => $this->auth->user()->username], 403);
}
return $next($request);
}