37 lines
756 B
PHP
37 lines
756 B
PHP
<?php
|
|
|
|
/* development only */
|
|
header("Access-Control-Allow-Origin: *");
|
|
|
|
require '../vendor/autoload.php';
|
|
|
|
use Lcobucci\JWT\Builder;
|
|
use Lcobucci\JWT\Signer\Hmac\Sha256;
|
|
|
|
$username = $_POST["userName"];
|
|
$password = $_POST["password"];
|
|
|
|
if( $username == "admin" && $password == "admin" ){
|
|
|
|
$signer = new Sha256();
|
|
$token = (new Builder())
|
|
->setIssuer("http://pugludos.com")
|
|
->setIssuedAt(time())
|
|
->set("userName", "ckoch")
|
|
->sign($signer, "testing")
|
|
->getToken();
|
|
|
|
$userData = array();
|
|
$userDatap["id"] = "12345";
|
|
$userDatap["username"] = "admin";
|
|
$userDatap["firstName"] = "TestFirst";
|
|
$userDatap["lastName"] = "TestLast";
|
|
$userDatap["token"] = (string)$token;
|
|
|
|
echo( json_encode( $userDatap ) );
|
|
}else{
|
|
http_response_code(400);
|
|
}
|
|
|
|
?>
|