diff --git a/.gitignore b/.gitignore index 89839572a..27c58390c 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,5 @@ sync.sh *.p12 *.swp .debug +.maintenance .htaccess diff --git a/application/controllers/User.php b/application/controllers/User.php index 5d5442bac..5908a5a1a 100644 --- a/application/controllers/User.php +++ b/application/controllers/User.php @@ -707,8 +707,13 @@ class User extends CI_Controller { $this->input->set_cookie($cookie); redirect('dashboard'); } else { - $this->session->set_flashdata('error', 'Incorrect username or password!'); - redirect('user/login'); + if(ENVIRONMENT == 'maintenance') { + $this->session->set_flashdata('notice', 'Sorry. This instance is currently in maintenance mode. If this message appears unexpectedly or keeps showing up, please contact an administrator. Only administrators are currently allowed to log in.'); + redirect('user/login'); + } else { + $this->session->set_flashdata('error', 'Incorrect username or password!'); + redirect('user/login'); + } } } } diff --git a/application/models/User_model.php b/application/models/User_model.php index c9116b5d0..3783f84a3 100644 --- a/application/models/User_model.php +++ b/application/models/User_model.php @@ -397,13 +397,29 @@ class User_Model extends CI_Model { $user_type = $this->session->userdata('user_type'); $user_hash = $this->session->userdata('user_hash'); - if($this->_auth($user_id."-".$user_type, $user_hash)) { - // Freshen the session - $this->update_session($user_id); - return 1; - } else { - $this->clear_session(); - return 0; + if(ENVIRONMENT != 'maintenance') { + if($this->_auth($user_id."-".$user_type, $user_hash)) { + // Freshen the session + $this->update_session($user_id); + return 1; + } else { + $this->clear_session(); + return 0; + } + } else { // handle the maintenance mode and kick out user on page reload if not an admin + if($user_type == '99') { + if($this->_auth($user_id."-".$user_type, $user_hash)) { + // Freshen the session + $this->update_session($user_id); + return 1; + } else { + $this->clear_session(); + return 0; + } + } else { + $this->clear_session(); + return 0; + } } } else { return 0; @@ -417,7 +433,15 @@ class User_Model extends CI_Model { if($u->num_rows() != 0) { if($this->_auth($password, $u->row()->user_password)) { - return 1; + if (ENVIRONMENT != "maintenance") { + return 1; + } else { + if($u->row()->user_type != 99){ + return 0; + } else { + return 1; + } + } } } return 0; diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index 497c4fd8c..1eb5e9d38 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -69,7 +69,13 @@