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

25
app/api/AuthApi.php Normal file
View File

@@ -0,0 +1,25 @@
<?php
class AuthApi {
static function login(){
$token = (new ApiManager)->getToken($this->input->username,$this->input->password);
if (!$token) {
throw new Exception("Auth failed", 401);
}
$this->response(['token' => $token]);
}
static function logout(){
$authenticationBearrer = $_SERVER['HTTP_AUTHORIZATION'];
if (!(new ApiManager)->deleteToken($authenticationBearrer)) {
throw new Exception("logout Failed", 401);
}
}
static function registration(){
}
static function restartPassword(){
}
}