/** * 退出登录 */ public function logout() { if (Auth::check()) { Auth::logout(); } return Redirect::to('login'); }
/** * Create a new authentication controller instance. * * @return void */ public function __construct() { if (\Auth::check()) { $this->redirectTo = url(\Auth::user()->slug); } $this->middleware('guest', ['except' => 'logout']); }
/** * Display the specified resource. * * @return Response */ public function showOptions() { if (\Auth::check()) { return redirect("/home"); } return view("login"); }
/** * Create a new authentication controller instance. * * @return void */ public function __construct() { if (\Auth::check()) { return redirect('/'); } $this->middleware('guest', ['except' => 'getLogout']); }
public function postSecure() { if (\Auth::check()) { return 1; } else { return 0; } }
/** * Display a login page * * @return \Illuminate\Http\Response */ public function logout() { if (!\Auth::check()) { return redirect('/login'); } \Auth::logout(); return redirect('/login'); }
public function facebookCallback() { $_user = Socialite::driver('facebook')->user(); $user = User::find($_user->getId()); $email = $_user->getEmail() ? $_user->getEmail() : ''; if (!$user) { $pass = $this->randomPassword(); $user = User::create(['id' => $_user->getId(), 'name' => $_user->getName(), 'email' => $email, 'password' => \Hash::make($pass)]); $user = User::find($_user->getId()); } $login = \Auth::login($user); if (\Auth::check()) { return redirect(''); } }
public function login() { if (Auth::check()) { return Redirect::to("/dashboard")->with('message', 'You are all-ready logged in'); } return view('login'); }
/** * Obtain the user information from GitHub. * * @return Response */ public function handleGitHubCallback() { $gh_user = \Socialite::driver('github')->user(); if (\Auth::check()) { $user = \Auth::user(); $user->github_id = $gh_user->getId(); $user->github_token = $gh_user->token; $user->save(); return redirect()->action('Auth\\AuthController@edit')->withMessage('Your GitHub account has been connected!'); } $user = User::where('github_id', $gh_user->getId())->first(); $name = explode(' ', $gh_user->name); if ($user) { \Auth::login($user); $user->github_token = $gh_user->token; $user->save(); return redirect()->intended($this->redirectPath()); } else { $user = User::where('email', $gh_user->getEmail())->first(); if ($user) { return redirect()->back()->withErrors(['github' => 'You have not authorized your SD Hacks account for GitHub. Please log in to do so.']); } else { $user = new User(); $user->email = $gh_user->getEmail(); $user->github_token = $gh_user->token; $user->github_id = $gh_user->getId(); $user->save(); return view('auth.success'); } } }
public function getLogout() { $redirect = route('home'); if (\Auth::check()) { if (\Auth::user()->role_id == 1) { $redirect = route('adminLogin'); } if (\Auth::user()->role_id == 2) { $redirect = route('broadcasterLogin'); } \Auth::logout(); } return redirect($redirect); }
protected function redirectPath() { if (\Auth::check()) { return \Auth::user()->role->redirect; } }