Protect whole site with login?



  • I would like to protect the whole NodeBB site requiring users to log in to see anything. Ideally I would like the starpage to be a login form (I think I know how to do that with a custom home page and html widget). I've removed guest access to all categories and also removed all navigation options for non logged in users. But routes like /recent are still accessible by just typing the address in the url bar...


  • Admin

    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. This will work even on other routes like /recent.


  • Community Rep

    @osirisguitar Just go to Admin -> General -> Navigation, click on the Recent icon (the clock) and turn on "Only display to logged in users"


  • Plugin & Theme Dev

    @Bri I think he already did that. That just removes the icon from the header. His point is... users can still type the url in the address bar (mysite.com/recent) for recent route to access it.


  • Swedes

    You can make an ugly .htaccess file / Nginx conf! :) I guess that sucks :P



  • @Jenkler How would you make a .htaccess that knows if the user is logged in?



  • @julian Any examples of html code with scripting that does that? (or something else, I'm a developer but don't really know where to start looking).


  • Swedes

    .htaccess does not work that way! You are logged in until you close the browser.


  • Community Rep

    @pichalite I'm doing this exact thing on my forum, so I know it's possible to do without using a script or .htaccess file...

    I'm pretty sure if you've disabled guest access for all categories, even if navigating directly to /recent, an anonymous user would not be able to see it.

    EDIT: @osirisguitar did I misunderstand? was your intent to disallow guest viewing of /recent? or to redirect any protected endpoint?



  • @Bri No, you understood right. I just want to disable /recent (and basically everything else except /) for anonymous users. And I've disabled guest access to both navigation and all categories (but you can still access it as anonymous)


  • Community Rep

    So something like this, right?

    0_1471665135330_upload-da3ef477-3a80-4dbb-9aad-7923cfaf75c3



  • ive done something like this, change the links in navigation to require to be logged in. only link i have on my main forum, is the login link, everythign else is taken away


Log in to reply
 

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.