I attended last weeks new user webinar and a question was raised about creating a single login page for all users so you could just use one URL. I appreciate that this is a variation on the article written by Danielle on the Knowledge Base, however, I thought I’d share my version on this method and hope that it may help someone.
Thanks for the video, Carl. Here’s a question. When the user logs out it puts him on the login page corresponding to the last page he or she was on, not necessarily the “Home” login page. How do you redirect the user to the home login when they logout from a random page?
Hey @PeterJurgen - I don’t see this as an issue.
If the user logs out and keeps the browser open, they will simply login to the page they left.
If they log out and the close the browser they would likely use a browser shortcut / bookmark to get them back to the homepage.
There isn’t really a reason, that I can see, to redirect them to the homepage on logout.
I’d imagine, if you need to, it could be done with JavaScript, however, I’m not a coder and have been using this for several years across multiple clients with no issues.
Using separate URL’s for various user roles always caused me more problems. The most common issue I had was when, for example, the warehouse manager changed his PC and didn’t migrate his bookmarks so went to the sales or finance department who gave them their URL.
When he logged in, it showed the pages he had access to, but the screen showed the “you don’t have access to this page” error as the URL was for a page he shouldn’t access.
@CarlHolmes Thanks for sharing.
@PeterJurgen To redirect all other login pages to the home login, you can add this to your Custom JS:
// This redirects all log in pages to the home log in
$(document).on('knack-view-render.any', function(event, view, data) {
// Replace `view_148` and `#login` with your home login
if (view.type == 'login' && view.key != 'view_148') {
window.location.replace('#login');
}
});
Cool. Thanks
Thanks Carl,
Very helpful, and very simple!
Cheers
@Craig_Anderson - glad that it made sense and hopefully it will be useful for you.
Thank you for this code, this is what I was looking for.
I have however a problem running it :
When I try to log in via another page, I am redirected to the “Home” login page (fine), but page loading seems to loop, and adding login information (email) is difficult, if not impossible.
Here an example :
Do you know what could be the problem ?
Thanks a lot
Hi @Francois,
I would like to investigate this for you. Would you mind scheduling a call with me by using this link here? I need to see your application in order to give a recommendation.
Thanks
One reason you might want to redirect to the “HOME” logion page is when using Single Sign On, because the SSO button(s) only show up on the home login page. That redirection code above works well, for me.
Thank you! This worked!