ryanlelek / Raneto

Markdown powered Knowledgebase Wiki for Node.js
https://raneto.com
MIT License
2.77k stars 446 forks source link

Redirect to Login page if not logged in currently #169

Open thomaspurk opened 7 years ago

thomaspurk commented 7 years ago

My goal is to force a log in for all users in order to access the knowledge base in any way. Currently, it seems that the configuration properties for authentication shows or hides the Log In button, providing the option to log in. This configuration does not require a log in for viewing no matter what combination of config auth settings are made.

I did find the following workaround, which seems to work on my dev machine to force the user to the Log In page on any page load.

Added the following lines to the Layout.html file between the head and body DOM elements.

{{^loggedIn}} {{#config.googleoauth}} <script> window.location = "{{config.base_url}}/auth/login";</script> {{/config.googleoauth}} {{^config.googleoauth}} <script> window.location = "{{config.base_url}}/login";</script> {{/config.googleoauth}} {{/loggedIn}}

This works because Layout.html is the full layout for all of the other partial layouts templates, except for Login.html which is it's own full layout. So far I have not seen any AJAX content loading in raneto, it relies instead on page loads so this code will fire on any content request other than the Login page.

ryanlelek commented 7 years ago

@thomaspurk please check out @mohammadrafigh 's contribution You'll have to clone the repo (master branch) and we'll publish to NPM soon

xhj967 commented 5 years ago

@ryanlelek does rane support win10? i have error when log in,could you please help me? this is logfiles

-- j yx8ff64yza 6 eev oa