Exemple #1
0
 private function handleRequest()
 {
     Log::debug('Controller', 'Handle request');
     $action = $this->request->action;
     if (empty($action)) {
         $this->index();
     } else {
         if (method_exists($this, $action)) {
             $this->{$action}();
         } else {
             throw new Exceptions\NotFoundException();
         }
     }
 }
Exemple #2
0
 public static function authenticate($username, $password)
 {
     Log::info('HackableUser', sprintf('Authenticate user: "******"', $username));
     $salt = self::retrieve_salt($username);
     Log::debug('HackableUser', sprintf('Salt: "%s"', $salt));
     $hashed_password = self::generate_hash($password, $salt);
     try {
         $user = self::retrieve($username, $hashed_password);
     } catch (\Lib\Exceptions\NotFoundException $e) {
         Log::info('User', sprintf('User not found: "%s"', $username));
         throw new \Lib\Exceptions\UnauthorizedException();
     }
     $user->create_token();
     return $user;
 }