From 1c247bc4073451ad156ecedfbd2f7ebe73b56c12 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Tue, 18 Aug 2015 22:01:18 +0200 Subject: Fix redirect URI when using multiple tabs If we store only the last called URI in the session we can't support multiple browser tabs that all need to log in again. Fix this by storing the URI in the URL. Also change a trim() to ltrim() so that the URI string we store keeps it's trailing slash. Signed-off-by: Florian Pritz --- application/controllers/user.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'application/controllers') diff --git a/application/controllers/user.php b/application/controllers/user.php index b432cba5e..eca0b7da3 100644 --- a/application/controllers/user.php +++ b/application/controllers/user.php @@ -44,8 +44,18 @@ class User extends MY_Controller { function login() { + $redirect_uri = $this->input->get("redirect_uri"); $this->muser->require_session(); - $this->session->keep_flashdata("uri"); + + if (!preg_match('/^[0-9a-zA-Z\/_]*$/', $redirect_uri)) { + $redirect_uri = '/'; + } + + if ($this->muser->logged_in()) { + redirect($redirect_uri); + } + + $this->data['redirect_uri'] = $redirect_uri; if ($this->input->post('process') !== false) { $username = $this->input->post('username'); @@ -59,12 +69,7 @@ class User extends MY_Controller { $this->load->view($this->var->view_dir.'login', $this->data); $this->load->view('footer', $this->data); } else { - $uri = $this->session->flashdata("uri"); - if ($uri) { - redirect($uri); - } else { - redirect("/"); - } + redirect($redirect_uri); } } else { $this->load->view('header', $this->data); -- cgit v1.2.3-24-g4f1b