Authentication Endpoint

This commit is contained in:
JonatanRek
2020-04-25 18:04:02 +02:00
parent 8300e47b76
commit e4f37f7686
4 changed files with 45 additions and 4 deletions

View File

@@ -18,10 +18,10 @@ class ApiController {
}
protected function requireAuth(){
if (isset($this->headers['HTTP_AUTHORIZATION'])) {
if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
// TODO: call appropriate class/method
$authManager = new AuthManager();
$this->authenticated = $authManager>validateToken($this->headers['HTTP_AUTHORIZATION']);
$this->authenticated = $authManager>validateToken($_SERVER['HTTP_AUTHORIZATION']);
if(!$this->authenticated){
throw new Exception("Auth required", 401);
}