AuthApi fix, refactoring

This commit is contained in:
xinatorus 2020-04-27 19:42:05 +02:00
parent 09ad9c9eba
commit d137d08ff4

View File

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