You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Fipamo/brain/api/v1/AuthAPI.inc.php

64 lines
1.2 KiB
PHP

<?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;
}
}