<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Token{

    function __construct() {
        
    }
        /**
     * URL: http://localhost/CodeIgniter-JWT-Sample/auth/token
     * Method: GET
     */
    public function token_get($data)
    {
        $tokenData = array();
        $tokenData['id'] = $data; //TODO: Replace with data for token
        $output = AUTHORIZATION::generateToken($tokenData);
        return $output;
    }

    /**
     * Method: POST
     * Header Key: Authorization
     * Value: Auth token generated in GET call
     */
    public function token_post($headers)
    {        
        if (array_key_exists('Authorization', $headers) && !empty($headers['Authorization'])) {
            $decodedToken = AUTHORIZATION::validateToken($headers['Authorization']);
            if ($decodedToken != false) {
                return true;
            }
            else
                return false;
        }        
    }
}
?>