Skip to content
Snippets Groups Projects
current.php 674 B
Newer Older
root's avatar
root committed
<?php

${basename(__FILE__, '.php')} = function(){
    if($this->get_request_method() == "GET" and $this->isAuthenticated()){
        try{
            $data = [
                "username" => $this->getUsername(),
            ];
            $data = $this->json($data);
            $this->response($data, 200);
        } catch(Exception $e){
            $data = [
                "error" => $e->getMessage()
            ];
            $data = $this->json($data);
            $this->response($data, 403);
        }

    } else {
        $data = [
            "error" => "Bad request"
        ];
        $data = $this->json($data);
        $this->response($data, 400);
    }
};