2021-04-17 05:50:03 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class AuthAPI
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function status()
|
|
|
|
{
|
|
|
|
$result = [];
|
|
|
|
if (Auth::status()) {
|
|
|
|
$result = [
|
|
|
|
"message" => "Authorized",
|
|
|
|
"type" => "apiUseAuthorized",
|
|
|
|
"token" => Session::get("token"),
|
|
|
|
];
|
|
|
|
} else {
|
|
|
|
$result = [
|
|
|
|
"message" => "Not Authorized",
|
|
|
|
"type" => "apiUseNotAuthorized",
|
|
|
|
];
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function login($body)
|
|
|
|
{
|
|
|
|
$result = [];
|
|
|
|
switch (Auth::login($body)) {
|
|
|
|
case "no_name":
|
|
|
|
$result = [
|
|
|
|
"message" => "Need to see some id, champ",
|
|
|
|
"type" => "requestLame",
|
|
|
|
];
|
|
|
|
break;
|
|
|
|
case "bad_pass":
|
|
|
|
$result = [
|
|
|
|
"message" => "Check your password, sport",
|
|
|
|
"type" => "requestLame",
|
|
|
|
];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$result = [
|
|
|
|
"message" => "Welcome back",
|
|
|
|
"type" => "requestGood",
|
|
|
|
];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function logout($body)
|
|
|
|
{
|
|
|
|
Auth::logout($body);
|
|
|
|
$result = [
|
|
|
|
"message" => "Till next time, g.",
|
|
|
|
"type" => "TASK_LOGOUT",
|
|
|
|
];
|
|
|
|
return $result;
|
|
|
|
}
|
2021-05-10 21:40:55 +02:00
|
|
|
public static function requestSecret($body)
|
|
|
|
{
|
|
|
|
$result = Auth::findSecret($body);
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
public static function resetPassword($body)
|
|
|
|
{
|
|
|
|
$result = Auth::makeNewPassword($body);
|
|
|
|
return $result;
|
|
|
|
}
|
2021-04-17 05:50:03 +02:00
|
|
|
}
|