PHP_SMART_HOME_V3/app/api/AuthApi.php

26 lines
555 B
PHP
Raw Permalink Normal View History

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