63eaba08e2
I needed some consistent php formatting, so I plugged in a php fixer config and then reformatted all PHP files so it's all consistent. Fixed an ID issue with the page-edit template that was causing page editing to fail.
77 lines
1.8 KiB
PHP
77 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace brain\api\v1;
|
|
|
|
use brain\data\Auth;
|
|
use brain\data\Session;
|
|
|
|
class AuthAPI
|
|
{
|
|
public function __construct()
|
|
{
|
|
}
|
|
public static function status()
|
|
{
|
|
$result = [];
|
|
//internal check for admin action
|
|
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;
|
|
}
|
|
public static function requestSecret($body)
|
|
{
|
|
$result = Auth::findSecret($body);
|
|
return $result;
|
|
}
|
|
public static function resetPassword($body)
|
|
{
|
|
$result = Auth::makeNewPassword($body);
|
|
return $result;
|
|
}
|
|
}
|