Esempio n. 1
0
 function __isAllowed()
 {
     //Get Token from header and check against server side
     $header = getallheaders();
     if (isset($header['Token']) || isset($header['token'])) {
         $token = $header['Token'] ? $header['Token'] : $header['token'];
         //Check token against db then hold the token in static class for referncing later
         $statement = 'SELECT userId, token, role, email, serial, status FROM user WHERE token = :token';
         $bind = array('token' => $token);
         $row = Db::getRow($statement, $bind);
         if ($row['userId'] > 0) {
             \TTO::setUserId($row['userId']);
             \TTO::setToken($row['token']);
             \TTO::setRole($row['role']);
             \TTO::setEmail($row['email']);
             \TTO::setSerial($row['serial']);
             \TTO::setStatus($row['status']);
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }