<?php

namespace Shared;

class LoginREST extends \Shared\AbstractREST
{
    protected function getRespond($data)
    {
        return $this->respondGetLogin($data);    
    }
    protected function postRespond($data)
    {
       switch ($this->class)
       {
           case "logout": return $this->respondPostLogout($data);
           default: return $this->respondPostLogin($data);
       }
    }

    private function respondPostLogin($data)
    {
        \Shared\Authentication::Authenticate();
        return \Shared\Authentication::GetLoggedUser();
    }

    private function respondPostLogout($data)
    {
        return \Shared\Authentication::Logout();
    }

    private function respondGetLogin($data)
    { 
        return \Shared\Authentication::GetLoggedUser();
    }
}