From d137d08ff4d0acbc23d30c225862a50b86d1877c Mon Sep 17 00:00:00 2001 From: xinatorus Date: Mon, 27 Apr 2020 19:42:05 +0200 Subject: [PATCH] AuthApi fix, refactoring --- app/api/AuthApi.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/app/api/AuthApi.php b/app/api/AuthApi.php index ae8c00e..4d58d8e 100644 --- a/app/api/AuthApi.php +++ b/app/api/AuthApi.php @@ -1,25 +1,25 @@ getToken($this->input->username,$this->input->password); - if (!$token) { - throw new Exception("Auth failed", 401); - } - $this->response(['token' => $token]); - } + public 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); - } - } + 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(){ - - } -} \ No newline at end of file + } + + public function restartPassword(){ + + } +}