PHP_SMART_HOME_V3/app/api/AuthApi.php

26 lines
527 B
PHP
Raw Normal View History

2020-04-25 16:04:02 +00:00
<?php
class AuthApi {
2020-04-27 17:42:05 +00:00
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]);
}
2020-04-25 16:04:02 +00:00
2020-04-27 17:42:05 +00:00
public function logout(){
$authenticationBearrer = $_SERVER['HTTP_AUTHORIZATION'];
if (!(new ApiManager)->deleteToken($authenticationBearrer)) {
throw new Exception("logout Failed", 401);
}
}
2020-04-25 16:04:02 +00:00
2020-04-27 17:42:05 +00:00
public function registration(){
2020-04-25 16:04:02 +00:00
2020-04-27 17:42:05 +00:00
}
public function restartPassword(){
}
}