Helper\LoginFilter::afterRoute PHP Method

afterRoute() public method

public afterRoute ( &$className, &$method )
    public function afterRoute(&$className, &$method)
    {
        $user = User::getCurrent();
        $reflection = new ReflectionMethod($className, $method);
        $docComment = $reflection->getDocComment();
        // $this->isJson = $this->isJSON($docComment);
        if (strpos($docComment, '@Authorization') !== false && !$user) {
            $this->black = true;
        }
        $reflection = new ReflectionObject(new $className());
        $docCommentC = $reflection->getDocComment();
        if (strpos($docCommentC, '@Authorization') !== false && !$user) {
            $this->black = true;
        }
        if (strpos($docComment, '@Admin') !== false || strpos($docCommentC, '@Admin') !== false) {
            if ($user && !$user->isAdmin()) {
                $this->data['message'] = '你不是管理员,无法访问此页面';
                $this->black = true;
            }
        }
        if ($this->black) {
            if ($this->isJson) {
                Template::setContext($this->data);
                Filter::preRender();
            } else {
                Message::show($this->data['message'], 'auth/login', 3);
            }
        }
    }