Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- class Login extends Controller
- {
- private $params;
- private $username;
- private $password;
- private $user_info;
- function Login()
- {
- parent::Controller();
- $this->load->model('login/loginModel');
- }
- function Index()
- {
- if ($this->auth->check_logged(TRUE) == true){
- redirect('/home', 'refresh');
- } else {
- $this->load->helper('form');
- if ($_POST) {
- $this->username = $this->input->post('frm-login-user', true);
- $this->password = $this->input->post('frm-login-pass', true);
- if (!empty($this->username) || !empty($this->password)) {
- if ($this->user_info = $this->loginModel->checkLogin($this->username, $this->
- password)) {
- if ($this->user_info->status == 3) {
- alertSetMsg('Sua conta está identificada como SOB AVISO por motivos administrativos. Infelizmente durante este período você não poderá efetuar a identificação e ter acesso.',
- 'error');
- redirect('/login/', 'refresh');
- } elseif ($this->user_info->status == 2) {
- alertSetMsg('Sua conta está identificada como SUSPENSA por motivos administrativos. Aguarde o contato do administrador ou algumas horas para liberação da mesma',
- 'error');
- redirect('/login/', 'refresh');
- } elseif ($this->user_info->status == 1) {
- $this->session->set_userdata('user_logged', array('user_id' => $this->user_info->
- id, 'user_name' => $this->user_info->name, 'user_email' => $this->user_info->
- email, 'user_status' => $this->user_info->status, 'user_privileges' => $this->
- user_info->privileges, 'logged' => 1, 'login_start' => date('Y-m-d H:i:s')));
- redirect('/home/', 'refresh');
- }
- } else {
- alertSetMsg("E-mail/Senha inválidos, tente novamente.");
- redirect('/login/', 'refresh');
- }
- } else {
- alertSetMsg("Preencha todos os campos corretamente.");
- redirect('/login/', 'refresh');
- }
- } else {
- $this->load->view('login/login');
- }
- }
- }
- function logout()
- {
- if ($this->loginModel->logout()) {
- redirect('/login/', 'refresh');
- } else {
- redirect('home/', 'refresh');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement