コード例 #1
0
 /**
  * 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();
         }
     }
 }
コード例 #2
0
ファイル: logout.php プロジェクト: mgilangjanuar/join_ristek
 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();
     }
 }
コード例 #3
0
ファイル: logout.php プロジェクト: jundialwan/oprecristek2016
 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();
     }
 }
コード例 #4
0
 public function index()
 {
     if (!SSO::check()) {
         SSO::authenticate();
     }
     $user = SSO::getUser();
     $userdata = array('username' => $user->username, 'name' => $user->name, 'npm' => $user->npm, 'angkatan' => $this->parseTahunAngkatan($user->npm), 'jurusan' => $user->study_program, 'biohash' => $this->hashingBio($user->username, $user->npm));
     // hanya angkatan 2013-2015 yang diperbolehkan daftar
     if ($userdata['angkatan'] != '2013' & $userdata['angkatan'] != '2014' & $userdata['angkatan'] != '2015' | $user->faculty != 'ILMU KOMPUTER') {
         redirect(site_url());
     }
     // tutup pendaftaran
     if (time() > strtotime('6th February 2016 23:55:00.0') - (21 * 60 + 30) & !(time() > strtotime('8th February 2016 19:30:00.0') - (21 * 60 - 30)) & !$this->biodata->isUserRegistered($user->username) & !$this->isAdmin($user->username)) {
         // registration closed
         redirect(site_url());
     }
     // re-set session
     $this->session->unset_userdata('userdata');
     $this->session->set_userdata('userdata', $userdata);
     // check if user is admin
     if ($this->useradmin->isAdmin($user->username)) {
         // redirect to admin747835
         redirect(site_url('admin747835'));
     }
     // check if user exist or not
     if ($this->biodata->isUserRegistered($user->username)) {
         // user exist
         // redirect to dashboard
         redirect(site_url('dashboard'));
     } else {
         // user not exist
         // create initial data in database
         if (!$this->biodata->get($user->username)) {
             $this->saveUserDataToDatabase($userdata);
         }
         // redirect to form
         redirect(site_url('register'));
     }
 }
コード例 #5
0
 public function index()
 {
     if (time() < strtotime('26th January 2016 18:16:00.0') - (21 * 60 + 30)) {
         redirect(site_url());
     }
     if (!SSO::check()) {
         SSO::authenticate();
     }
     $user = SSO::getUser();
     $userdata = array('username' => $user->username, 'name' => $user->name, 'npm' => $user->npm, 'angkatan' => $this->parseTahunAngkatan($user->npm), 'jurusan' => $user->study_program, 'biohash' => $this->hashingBio($user->username, $user->npm));
     // 2012-- & the other is not allowed, redirect to index
     if ($userdata['angkatan'] != '2013' & $userdata['angkatan'] != '2014' & $userdata['angkatan'] != '2015' & $user->faculty != 'ILMU KOMPUTER') {
         redirect(site_url());
     }
     // re-set session
     $this->session->unset_userdata('userdata');
     $this->session->set_userdata('userdata', $userdata);
     // check if user is admin
     if ($this->useradmin->isAdmin($user->username)) {
         // redirect to admin747835
         redirect(site_url('admin747835'));
     }
     // check if user exist or not
     if ($this->biodata->isUserRegistered($user->username)) {
         // user exist
         // redirect to dashboard
         redirect(site_url('dashboard'));
     } else {
         // user not exist
         // create initial data in database
         if (!$this->biodata->get($user->username)) {
             $this->saveUserDataToDatabase($userdata);
         }
         // redirect to form
         redirect(site_url('register'));
     }
 }
コード例 #6
0
 /**
  * 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');
 }
コード例 #7
0
ファイル: UserController.php プロジェクト: pandhu/databasepkm
 public function logout()
 {
     Session::flush();
     SSO::logout();
     return Redirect::action('UserController@login');
 }
コード例 #8
0
ファイル: welcome.php プロジェクト: jundialwan/try_sso
 /**
  * Index Page for this controller.
  *
  * Maps to the following URL
  * 		http://example.com/index.php/welcome
  *	- or -  
  * 		http://example.com/index.php/welcome/index
  *	- or -
  * Since this controller is set as the default controller in 
  * config/routes.php, it's displayed at http://example.com/
  *
  * So any other public methods not prefixed with an underscore will
  * map to /index.php/welcome/<method_name>
  * @see http://codeigniter.com/user_guide/general/urls.html
  */
 public function index()
 {
     SSO::authenticate();
     $user = SSO::getUser();
     echo 'Nama: ' . $user->username . '</br>' . 'NPM: ' . $user->npm . '</br>' . 'Username: '******'</br>' . 'Role: ' . $user->role . '</br>' . 'Organization: ' . $user->org_code . '</br>' . 'Faculty: ' . $user->faculty . '</br>' . 'Study Program: ' . $user->study_program . '</br>' . 'Educational Program: ' . $user->educational_program;
 }