Logout

\Modules\Api\User\Logout

Methods

post

<?php public static function \Modules\Api\User\Logout::post($token = null)

Description
Log out the user (destroy the token).

Parameters

  • token
    User's token

Return

{
  "success": {
    "message": "Request was successful",
    "key": "ok",
    "code": 200
  }
}

Example

Here is a simple example of what your logout webservice might look like.

<?php

namespace App\Modules\Users;

use \Lib\Controller\WSController;
use \Modules\Api\User\Logout as LogoutController;

/**
 * Class Logout
 * @package App\Modules\Users
 */
class Logout extends \Modules\Elements
{

    /**
     * @description Log out the user.
     * @param WSController $controller
     * @param array $params
     * @doc string $token user's token
     * @return array|boolean
     * @throws \Exception
     */
    public static function post(WSController $controller, $params = array())
    {

        $post = \Lib\DataRequest::getInstance()->get('post');

        $token = !empty($_SERVER['AP-UTOKEN']) ? $_SERVER['AP-UTOKEN'] : $post['token'];

        return LogoutController::post($token);
    }
}