-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
27 lines (23 loc) · 663 Bytes
/
api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
/*
* Copyright (c) 2021 WüSpace e. V. <kontakt@wuespace.de>
*/
use function wuespace\jwt\auth\signIn;
require_once 'system/setup.php';
if (isset($_GET['source']) && isDomainRegistered($_GET['source'])) {
header('Access-Control-Allow-Origin: ' . $_GET['source']);
header('Access-Control-Allow-Headers: *');
if (isset($_POST['user'], $_POST['pass'])) {
if ($token = signIn($_POST['user'], $_POST['pass'])) {
echo $token;
} else {
http_response_code(401);
echo 'Bad credentials';
}
} else {
http_response_code(400);
echo 'Please enter your user data first';
}
} else {
http_response_code(400);
}