<?php

namespace App\System\Middleware;
use App\System\Basic\beRouter;
use App\System\Model\UserGroupModel;
use App\System\Vendor\Auth;
use App\System\Vendor\beLanguage;

class AuthMiddleware {
    //@ioncube.dk beEncrypt("be_diyocp","handle") -> "f884b2f4d6392ab447669f33514c9873" RANDOM
    public function handle(){
        global $be;
        beLanguage::beReadLang("auth");
        $user = $be->user;
        if(!$user["uid"]){
            $method = beRouter::beGetMethod();
            if($method == "get"){
                beRouter::beRedirect(beGetRoute("auth.login"));
                exit;
            }
            else{
                echo beAjaxError(["message" => beGetLang("need_account")]);
                exit;
            }
        }
    }
}

?>