| Server IP : 188.114.97.2 / Your IP : 104.23.197.231 Web Server : Apache/2.4.59 (Debian) System : Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64 User : edlftp ( 1002) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/nicolasj/www/sms.formationlangues.be/application/controllers/BO/ |
Upload File : |
<?php
if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
class GLogin extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('crud_model');
$this->load->model('users_model');
$this->load->database();
$this->load->library('google');
}
//Default function, redirects to logged in user area
public function index()
{
echo "hell";
var_dump($this->session->all_userdata());
}
public function login()
{
$token = trim($this->input->post('token'));
$email = trim($this->input->post('email'));
//$name = trim($this->input->post('name'));
$validated = $this->google->check_token($token);
if ($validated) {
if ($this->users_model->email_exist($email)) {
$this->validate_login($email);
echo "1";
//$this->users_model->log_connecion();
} else {
echo "0";
}
} else {
echo "-1";
}
}
public function validate_login($email = "")
{
$user = $this->db->select('u.*,r.code AS role')
->join('role AS r', 'r.role_id=u.role_id', 'inner')
->where('u.email', $email, true)->get('user AS u', 1)->row_array();
if (empty($user)) {
$this->error(get_phrase('email_is_not_found'));
} elseif ($user['is_active'] == 0) {
$this->error(get_phrase('user_is_not_active'));
} else {
$this->session->set_userdata(array(
'userID' => $user['user_id']
, $user['role'] . '_login' => '1'
, $user['role'] . '_id' => $user['user_id']
, 'login_user_id' => $user['user_id']
, 'name' => $user['name']
, 'login_type' => $user['role']
));
$rolesToIgnore = array('admin','teacher','student','parent');
}
//var_dump($this->session->all_userdata());
}
}