From 01e6e12220bd5edf1b55afef41c4dd2847882ea0 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 21 Mar 2014 22:13:39 -0500 Subject: [PATCH] Redirect to originally-requested page on login Instead of always showing the tickets page --- include/client/login.inc.php | 6 +++--- login.php | 9 +++++---- open.php | 13 ++++++++----- secure.inc.php | 4 +++- view.php | 3 +++ 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/include/client/login.inc.php b/include/client/login.inc.php index 806560464..c4b865d2e 100644 --- a/include/client/login.inc.php +++ b/include/client/login.inc.php @@ -12,7 +12,7 @@ $content = Page::lookup(Page::getIdByType('registration-policy')); <form action="login.php" method="post" id="clientLogin"> <?php csrf_token(); ?> <div style="display:table-row"> - <div style="width:40%;display:table-cell"> + <div style="width:40%;display:table-cell;box-shadow: 12px 0 15px -15px rgba(0,0,0,0.4);padding-left: 2em;"> <strong><?php echo Format::htmlchars($errors['login']); ?></strong> <br> <div> @@ -27,11 +27,11 @@ $content = Page::lookup(Page::getIdByType('registration-policy')); <input class="btn" type="submit" value="Sign In"> </p> </div> + <div style="display:table-cell;padding-left: 2em;"> <?php if ($cfg && $cfg->isClientRegistrationEnabled()) { ?> - <div style="display:table-cell;box-shadow: -9px 0 15px -12px rgba(0,0,0,0.3);padding-left: 2em;"> Not yet registered? <a href="account.php?do=create">Create an account</a> - </div> <?php } ?> + </div> </div> </form> <br> diff --git a/login.php b/login.php index 4751f7497..7e7e35cd6 100644 --- a/login.php +++ b/login.php @@ -30,15 +30,16 @@ if ($_POST) { $errors['err'] = 'Valid username or email address is required'; elseif (($user = UserAuthenticationBackend::process($_POST['luser'], $_POST['lpasswd'], $errors))) { - Http::redirect('tickets.php'); - $_POST = null; + Http::redirect($_SESSION['_client']['auth']['dest'] ?: 'tickets.php'); } elseif(!$errors['err']) { $errors['err'] = 'Invalid email or ticket number - try again!'; } } -$nav = new UserNav(); -$nav->setActiveNav('status'); +if (!$nav) { + $nav = new UserNav(); + $nav->setActiveNav('status'); +} require CLIENTINC_DIR.'header.inc.php'; require CLIENTINC_DIR.$inc; require CLIENTINC_DIR.'footer.inc.php'; diff --git a/open.php b/open.php index 719f35cc8..6bcecf5e5 100644 --- a/open.php +++ b/open.php @@ -17,7 +17,7 @@ require('client.inc.php'); define('SOURCE','Web'); //Ticket source. $ticket = null; $errors=array(); -if($_POST): +if ($_POST) { $vars = $_POST; $vars['deptId']=$vars['emailId']=0; //Just Making sure we don't accept crap...only topicId is expected. if ($thisclient) { @@ -60,10 +60,14 @@ if($_POST): }else{ $errors['err']=$errors['err']?$errors['err']:'Unable to create a ticket. Please correct errors below and try again!'; } -endif; +} //page $nav->setActiveNav('new'); +if ($cfg->isClientLoginRequired() && !$thisclient) { + require_once 'secure.inc.php'; +} + require(CLIENTINC_DIR.'header.inc.php'); if($ticket && ( @@ -76,9 +80,8 @@ if($ticket array_fill(0, 3, 'XXXXXX'), $page->getBody() ))); -} elseif ($cfg->isClientLoginRequired() && !$thisclient) { - require(CLIENTINC_DIR.'login.inc.php'); -} else { +} +else { require(CLIENTINC_DIR.'open.inc.php'); } require(CLIENTINC_DIR.'footer.inc.php'); diff --git a/secure.inc.php b/secure.inc.php index bf6a75b3e..8a0116306 100644 --- a/secure.inc.php +++ b/secure.inc.php @@ -20,7 +20,9 @@ require_once('client.inc.php'); //Client Login page: Ajax interface can pre-declare the function to trap logins. if(!function_exists('clientLoginPage')) { function clientLoginPage($msg ='') { - global $ost; + global $ost, $cfg, $nav; + $_SESSION['_client']['auth']['dest'] = + '/' . ltrim($_SERVER['REQUEST_URI'], '/'); require('./login.php'); exit; } diff --git a/view.php b/view.php index b8590aab4..e4e143b8c 100644 --- a/view.php +++ b/view.php @@ -23,6 +23,9 @@ $user = UserAuthenticationBackend::processSignOn($errors); if ($user && $user->getTicketId()) Http::redirect('tickets.php?id='.$user->getTicketId()); +$nav = new UserNav(); +$nav->setActiveNav('status'); + //Simply redirecting to tickets.php until multiview is implemented. require('tickets.php'); ?> -- GitLab