diff --git a/include/class.auth.php b/include/class.auth.php index e3bce85fe5b83f8e5c11c626ac6115845a185a18..cf16dd3b9aa0eb8d83a5dbf89e2b838c92f50ea5 100644 --- a/include/class.auth.php +++ b/include/class.auth.php @@ -749,4 +749,36 @@ class AuthTokenAuthentication extends UserAuthenticationBackend { } UserAuthenticationBackend::register(AuthTokenAuthentication); +//Simple ticket lookup backend used to recover ticket access link +class AccessLinkAuthentication extends UserAuthenticationBackend { + static $name = "Ticket Access Link Authentication"; + static $id = "authlink"; + + function authenticate($email, $number) { + + if (!($ticket = Ticket::lookupByNumber($number)) + || !($user=User::lookup(array('emails__address' => + $email)))) + return false; + + //Ticket owner? + if ($ticket->getUserId() == $user->getId()) + $user = $ticket->getOwner(); + //Collaborator? + elseif (!($user = Collaborator::lookup(array('userId' => + $user->getId(), 'ticketId' => + $ticket->getId())))) + return false; //Bro, we don't know you! + + + return new ClientSession($user); + } + + //We are not actually logging in the user.... + function login($user, $bk) { + return true; + } + +} +UserAuthenticationBackend::register(AccessLinkAuthentication); ?>