From 9037bf8dadb5cf33bf51f71f7ba3c3d013aebdc4 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Thu, 2 May 2024 12:12:40 +0100 Subject: [PATCH] Catch any errors --- application/controllers/User.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/application/controllers/User.php b/application/controllers/User.php index 75bb78de..df6dceaa 100644 --- a/application/controllers/User.php +++ b/application/controllers/User.php @@ -893,14 +893,21 @@ class User extends CI_Controller { // Read the cookie remeber_me and log the user in if($this->input->cookie(config_item('cookie_prefix').'remember_me')) { - $encrypted_string = $this->input->cookie(config_item('cookie_prefix').'remember_me'); - $decrypted_string = $this->encryption->decrypt($encrypted_string); - $this->user_model->update_session($decrypted_string); - $this->user_model->set_last_login($decrypted_string); - - log_message('debug', '[User ID: '.$decrypted_string.'] Remember Me Login Successful'); - - redirect('dashboard'); + try { + $encrypted_string = $this->input->cookie(config_item('cookie_prefix').'remember_me'); + $decrypted_string = $this->encryption->decrypt($encrypted_string); + $this->user_model->update_session($decrypted_string); + $this->user_model->set_last_login($decrypted_string); + + log_message('debug', '[User ID: '.$decrypted_string.'] Remember Me Login Successful'); + + redirect('dashboard'); + } catch (Exception $e) { + // Something went wrong with the cookie + log_message('error', 'Remember Me Login Failed'); + $this->session->set_flashdata('error', 'Remember Me Login Failed'); + redirect('user/login'); + } } if ($this->form_validation->run() == FALSE) {