/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|null $guard * @return mixed */ public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->check()) { return $next($request); } else { if (SSO::check()) { try { $userData = SSO::getUser(); } catch (Exception $e) { SSO::logout(); } if (substr($userData->npm, 0, 2) === "15" && $userData->faculty === "ILMU KOMPUTER") { $request->session()->put('sso', json_encode(SSO::getUser())); if (Auth::guard($guard)->attempt(['username' => $userData->username, 'password' => ''])) { return $next($request); } else { $id = DB::table('users')->insertGetId(['username' => $userData->username, 'fullname' => $userData->name, 'voted_threads' => "|", 'voted_replies' => "|"]); // Create folder for user Storage::makeDirectory('users/' . $id); Auth::guard($guard)->loginUsingId($id); return $next($request); } } return abort(401); } else { SSO::authenticate(); } } }
public function index() { if (time() < strtotime('26th January 2016 18:16:00.0') - (21 * 60 + 30)) { redirect(site_url()); } if (!$this->is_logged_in()) { redirect(site_url()); } else { # unset session data $this->session->unset_userdata('user_data'); # logout SSO SSO::logout(); } }
public function index() { // tutup pendaftaran if (time() > strtotime('6th February 2016 23:55:00.0') - (21 * 60 + 30) & !$this->isAdmin($user->username) & !(time() > strtotime('8th February 2016 19:30:00.0') - (21 * 60 + 30)) & !$this->biodata->isUserRegistered($user->username)) { // registration closed redirect(site_url()); } if (!$this->is_logged_in()) { redirect(site_url()); } else { # unset session data $this->unset_only(); # logout SSO SSO::logout(); } }
/** * Logout the user and delete all sessions. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function logout(Request $request) { if (!$request->session()->has('sso') && !Auth::check()) { SSO::logout(); } Auth::logout(); $request->session()->flush(); return redirect('/logout'); }
public function logout() { Session::flush(); SSO::logout(); return Redirect::action('UserController@login'); }