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