From 205ae826390ff5b7764db9c0d016fbce75237443 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Thu, 27 Mar 2014 15:36:01 -0500 Subject: [PATCH] Always enable ticket link by email page Regardless of the configuration of the help desk registration, allow users to receive ticket links via email. This patch enables the display and operation of the ticket access link unless a user login is requested by the user or specifically required by the system. --- include/class.auth.php | 16 +++++++--------- include/client/accesslink.inc.php | 13 +++++++++++-- include/client/header.inc.php | 2 +- login.php | 3 ++- tickets.php | 3 +++ view.php | 8 +++++--- 6 files changed, 29 insertions(+), 16 deletions(-) diff --git a/include/class.auth.php b/include/class.auth.php index a1b8c5220..816930400 100644 --- a/include/class.auth.php +++ b/include/class.auth.php @@ -448,7 +448,7 @@ abstract class UserAuthenticationBackend extends AuthenticationBackend { } function getAllowedBackends($userid) { - $backends = array(); + $backends = array('authlink'); $sql = 'SELECT A1.backend FROM '.USER_ACCOUNT_TABLE .' A1 INNER JOIN '.USER_EMAIL_TABLE.' A2 ON (A2.user_id = A1.user_id)' .' WHERE backend IS NOT NULL ' @@ -888,20 +888,18 @@ class AccessLinkAuthentication extends UserAuthenticationBackend { function authenticate($email, $number) { if (!($ticket = Ticket::lookupByNumber($number)) - || !($user=User::lookup(array('emails__address' => - $email)))) + || !($user=User::lookup(array('emails__address' => $email)))) return false; - //Ticket owner? + // Ticket owner? if ($ticket->getUserId() == $user->getId()) $user = $ticket->getOwner(); - //Collaborator? - elseif (!($user = Collaborator::lookup(array('userId' => - $user->getId(), 'ticketId' => - $ticket->getId())))) + // Collaborator? + elseif (!($user = Collaborator::lookup(array( + 'userId' => $user->getId(), + 'ticketId' => $ticket->getId())))) return false; //Bro, we don't know you! - return new ClientSession($user); } diff --git a/include/client/accesslink.inc.php b/include/client/accesslink.inc.php index f588f3249..183742d5a 100644 --- a/include/client/accesslink.inc.php +++ b/include/client/accesslink.inc.php @@ -10,7 +10,7 @@ link will be emailed to you.</p> <form action="login.php" method="post" id="clientLogin"> <?php csrf_token(); ?> <div style="display:table-row"> - <div style="display:table-cell;width:40%"> + <div style="width:40%;display:table-cell;box-shadow: 12px 0 15px -15px rgba(0,0,0,0.4);padding-right: 2em;"> <strong><?php echo Format::htmlchars($errors['login']); ?></strong> <br> <div> @@ -25,7 +25,16 @@ link will be emailed to you.</p> <input class="btn" type="submit" value="Email Access Link"> </p> </div> - <div style="display:table-cell"></div> + <div style="display:table-cell;padding-left: 2em;padding-right:90px;"> +<?php if ($cfg && $cfg->getClientRegistrationMode() !== 'disabled') { ?> + Have an account with us? + <a href="login.php?do=create">Sign In</a> <?php + if ($cfg->isClientRegistrationEnabled()) { ?> + or <a href="login.php?do=create">register for an account</a> <?php + } ?> to access all your tickets. +<?php +} ?> + </div> </div> </form> <br> diff --git a/include/client/header.inc.php b/include/client/header.inc.php index e7031dd3e..e6ea209f4 100644 --- a/include/client/header.inc.php +++ b/include/client/header.inc.php @@ -56,7 +56,7 @@ header("Content-Type: text/html; charset=UTF-8\r\n"); Guest User | <?php } if ($cfg->getClientRegistrationMode() != 'disabled') { ?> - <a href="<?php echo ROOT_PATH; ?>login.php">Log In</a> + <a href="<?php echo ROOT_PATH; ?>login.php">Sign In</a> <?php } } ?> diff --git a/login.php b/login.php index 41658e483..5d1faa1ec 100644 --- a/login.php +++ b/login.php @@ -24,7 +24,8 @@ define('OSTCLIENTINC',TRUE); //make includes happy require_once(INCLUDE_DIR.'class.client.php'); require_once(INCLUDE_DIR.'class.ticket.php'); -if ($cfg->getClientRegistrationMode() == 'disabled') +if ($cfg->getClientRegistrationMode() == 'disabled' + || isset($_POST['lticket'])) $inc = 'accesslink.inc.php'; else $inc = 'login.inc.php'; diff --git a/tickets.php b/tickets.php index 35bf1a0cf..9561da31d 100644 --- a/tickets.php +++ b/tickets.php @@ -32,6 +32,9 @@ if($_REQUEST['id']) { } } +if (!$ticket && $thisclient->isGuest()) + Http::redirect('view.php'); + //Process post...depends on $ticket object above. if($_POST && is_object($ticket) && $ticket->getId()): $errors=array(); diff --git a/view.php b/view.php index e4e143b8c..abf7d805a 100644 --- a/view.php +++ b/view.php @@ -19,13 +19,15 @@ require_once('client.inc.php'); // Try autologin the user // Authenticated user can be of type ticket owner or collaborator $errors = array(); -$user = UserAuthenticationBackend::processSignOn($errors); +$user = UserAuthenticationBackend::processSignOn($errors, false); 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'); +$inc = 'accesslink.inc.php'; +require CLIENTINC_DIR.'header.inc.php'; +require CLIENTINC_DIR.$inc; +require CLIENTINC_DIR.'footer.inc.php'; ?> -- GitLab