Example #1
0
 public static function isRegistered($forlife)
 {
     global $globals;
     $payload = '';
     $method = 'GET';
     $resource = '/api/1/user/' . $forlife . '/isRegistered';
     $timestamp = time();
     $message = implode('#', array($method, $resource, $payload, $timestamp));
     $token = $globals->xorg->hash;
     $sig = hash_hmac('sha256', $message, $token);
     $get = '?user='******'&timestamp=' . $timestamp . '&sig=' . $sig;
     $url = $globals->xorg->url . $resource . $get;
     $a = new xorgAPI($url);
     $a->exec();
     if ($a->http_code() == 404) {
         throw new xorgUnkonwnUserException("{$forlife} doesn't seem to exist");
     }
     $json = json_decode($a->response());
     return $json->isRegistered;
 }
Example #2
0
 public function handler_mails($page)
 {
     // TODO: use the forlife corresponding to x.edu instead of the hruid
     $forlife = S::user()->login();
     try {
         $xorgIsRegistered = xorgAPI::isRegistered($forlife);
     } catch (xorgUnkonwnUserException $e) {
         $xorgIsRegistered = null;
     }
     $page->assign('xorgRegistered', $xorgIsRegistered);
     $page->assign('user', S::user());
     $page->assign('title', 'Mes mails');
     $page->changeTpl('profile/mails.tpl');
 }