Frage

I'm using the Login module a bit differently than it is intended. Rather than only have the login module live on a separate page, I want the login module available on all pages. The problem is the login module that's on all pages doesn't receive redirect information. That info is generated by the Javascript that sends the user to the separate login page.

How can I make the login module redirect authenticated users to the page they logged in on? Preferably systematically with DNN, but I'm not above using Javascript or even jQuery to make this work.


Solution based off of Kyle Needham's response below

if( window.location.href == 'http://website.com/authenticated' ){
    window.location.href = sessionStorage.getItem('login_redirect');
}
else{
    sessionStorage.setItem('login_redirect', window.location.href);
}
War es hilfreich?

Lösung

On the page that the user logs in on you can set a sessionStorage item.

sessionStorage.setItem('login_redirect', window.location.href);

Then once login is done you can redirect them to the page they logged in on using.

window.location.href = sessionStorage.getItem('login_redirect');


A basic guide to dom storage can be found here.

Andere Tipps

you might want to use a (session) cookie that you call "auth_redirect" and the value would be the url who sends the user to the login module. alternativally you could redirect to the login module using a ?redirectUrl=/redirect/to/this/page/after/login querystring

session cookie apporach (using $.cookie)

$.cookie("auth_redirect", document.location.href);
// now redirect to login page
if (login === done) 
    document.location.href = $.cookie("auth_redirect") || "/";
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top