<?php // SSO library require_once __DIR__ . '/../../vendor/SSO/SSO/SSO.php'; use SSO\SSO; SSO::setCASPath(__DIR__ . '/../../vendor/CAS/CAS.php'); // require 'http://ristek.cs.ui.ac.id/sso-api/vendor/autoload.php' class Ssologin extends MY_Controller { public function __construct() { parent::__construct(); } 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
<?php require_once '/vendor/SSO/SSO/SSO.php'; use SSO\SSO; SSO::setCASPath('/vendor/CAS/CAS.php'); class Welcome extends CI_Controller { /** * 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; } } /* End of file welcome.php */ /* Location: ./application/controllers/welcome.php */