public function getAuthAction($token = null, $key = null) { if ($key) { if ($this->checkAuthKey($key)) { if ($token) { $usertoken = Usertoken::findTokenByID($token); if ($usertoken) { $this->rest_success(array("authdata" => unserialize($usertoken->authdata))); $usertoken->delete(); } else { $this->rest_error(array("name" => "Invaild Parameter", "message" => "Token not found")); } } else { $this->rest_error(array("name" => "Invaild Parameter", "message" => "Token is null")); } } else { $this->rest_error(array("name" => "Invaild Parameter", "message" => "Invaild Api Key")); } } else { $this->rest_error(array("name" => "Invaild Parameter", "message" => "Key is null")); } }
public static function findTokenByID($tokenID) { $token = Usertoken::findFirst(array("tokenid = :tokenid:", 'bind' => array('tokenid' => $tokenID))); return $token; }