PHP_SMART_HOME_V3/app/api/AuthApi.php

26 lines
529 B
PHP
Raw Normal View History

2020-04-25 18:04:02 +02:00
<?php
class AuthApi {
2020-04-27 19:42:05 +02:00
public function login(){
2020-05-12 19:25:08 +02:00
$token = (new AuthManager)->getToken($this->input->username,$this->input->password);
2020-04-27 19:42:05 +02:00
if (!$token) {
throw new Exception("Auth failed", 401);
}
$this->response(['token' => $token]);
}
2020-04-25 18:04:02 +02:00
2020-04-27 19:42:05 +02:00
public function logout(){
$authenticationBearrer = $_SERVER['HTTP_AUTHORIZATION'];
2020-05-12 19:25:08 +02:00
if (!(new AuthManager)->deleteToken($authenticationBearrer)) {
2020-04-27 19:42:05 +02:00
throw new Exception("logout Failed", 401);
}
}
2020-04-25 18:04:02 +02:00
2020-04-27 19:42:05 +02:00
public function registration(){
2020-04-25 18:04:02 +02:00
2020-04-27 19:42:05 +02:00
}
public function restartPassword(){
}
}