如何禁止游客浏览全站?



  • 在自带的管理板块我能禁止游客的大部分功能,但是游客仍然能通过直接输入url查看/users等内容.我希望将这些内容也保护起来,请问该如何设置?

    在英文官方论坛我搜索到相关的帖子,管理员是如此回答的

    "If you’ve removed find/access privileges for guests, then /recent shouldn’t show anything. If it does, then it’s showing topics from categories that guests have access to.

    Either way, you’ll probably want to add a snippet in your custom HTML (or in a footer widget) to check for user session and redirect. "

    其中的第二种办法该如何实现?我希望谁能给我一个代码片段的例子,实现游客输入任意url都跳转到登录界面,谢谢!



  • 又搜索了一会儿,自己写了一个代码片段

    <script>
    if (!app.user.uid && window.location.pathname !== '/login' && window.location.pathname !== '/register' ) {
        window.location.pathname = "/login";
    }
    </script>
    


  • @enigmaz 感谢您的支持


 

Powered by NodeBB © 2018 PA Team All Rights Reserved Accelerated by UPYUN . 苏ICP备17002503号-2