Example #1
0
 public function authenticateWithToken($token, $update_last_login = true)
 {
     $options = User::decodeToken($token);
     if (!empty($options) && !empty($options['hash']) && !empty($options['id'])) {
         $User = new User();
         $User = $User->find($options['id']);
         if (!empty($options['expires']) && $options['expires'] < Ak::getTimestamp()) {
             return false;
         }
         if ($options['hash'] == $User->getTokenHash($options)) {
             if ($update_last_login) {
                 $User->updateAttribute('last_login_at', Ak::getDate());
             }
             $this->setCurrentUser($User);
             return $User;
         }
     }
     return false;
 }