diff --git a/include/class.client.php b/include/class.client.php index 7464b841ca8ab7bfb5217d2965760ea99ff28fb9..cb247882e4045d058fd13ff418fb8f2c472fc795 100644 --- a/include/class.client.php +++ b/include/class.client.php @@ -239,5 +239,28 @@ class Client { return false; } + + static function authlogin($auth) { + //Expecting authtoken + // <user type><id of the user type>x<version id of the algo used>h<hash> + $matches = array(); + $regex='/^(?P<type>\w{1})(?P<id>\d+)x(?P<v>\d+)h(?P<hash>.*)$/i'; + if (!preg_match($regex, $auth, $matches)) + return false; + + switch($matches['type']) { + case 'c': //Collaborator c<id>x<algo id used>h<hash for algo> + if (($c = Collaborator::lookup($matches['id'])) + && strcasecmp($c->getAuthToken($matches['v']), $auth) == 0 + ) + return $c; + break; + case 'o': //Ticket owner + + break; + } + + return false; + } } ?> diff --git a/view.php b/view.php index 10e5374fe71b8dcf3551c0ee922ac5b4800e961a..5adb76b67d3b003bae2cd17b3031aba703162e0c 100644 --- a/view.php +++ b/view.php @@ -22,8 +22,10 @@ if(!$thisclient || !$thisclient->isValid()) { // * On login Client::login will redirect the user to tickets.php view. // * See TODO above for planned multi-view. $user = null; - if($_GET['t'] && $_GET['e'] && $_GET['a']) + if ($_GET['t'] && $_GET['e'] && $_GET['a']) $user = Client::login($_GET['t'], $_GET['e'], $_GET['a'], $errors); + elseif ($_GET['auth']) + var_dump(Client::authlogin($_GET['auth'])); //XXX: For now we're assuming the user is the ticket owner // (multi-view based on auth token will come later).