<?php
namespace Extension;
 use TCMS\HookExtension;
 use TCMS\TException;
 class AdminAuthHookDefault extends HookExtension {
 public function beforeModuleLoad($module) {
 if($module->authExtension === null && full_url() != url('/login')) {
 $auth = load_auth();
 if($auth) {
 $user = $auth->auth();
 if(!$user) {
 header("Location: " . $auth->loginUrl . '?redirect_url='.full_url());
 exit();
 }
 else {
 if($module->middleware(route_name(), $auth) === false) {
 throw new TException('Bạn không có quyền truy cập trang này', 401);
 }
 }
 }
 }
 }
 public function beforeViewLoad($view) {
 }
 }
 ?>