Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReturnUrl in passwordless.login.js #51

Closed
nicowitteman opened this issue Oct 29, 2022 · 3 comments
Closed

ReturnUrl in passwordless.login.js #51

nicowitteman opened this issue Oct 29, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@nicowitteman
Copy link

nicowitteman commented Oct 29, 2022

In passwordless.login.js, instead of setting window.location.href = "/index", I suggest to redirect to the ReturnUrl like so:

    let returnUrl = findGetParameter('ReturnUrl');
    if (!returnUrl) {
        returnUrl = getFolder();
    }
    window.location.href = returnUrl;

using these helper functions:

function findGetParameter(parameterName) {
    var result = null,
        tmp = [];
    location.search
        .substr(1)
        .split("&")
        .forEach(function (item) {
            tmp = item.split("=");
            if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
        });
    return result;
}

and

function getFolder() {
    var dir = "";
    try {
        dir = document.getElementById('BasePath').value;
    } catch (e) {
    }
    return dir;
}

combined with this line added to Login.cshtml:

<input type="hidden" id="BasePath" name="BasePath" value="@Url.Content("~")">

@damienbod damienbod added the enhancement New feature or request label Oct 29, 2022
@damienbod
Copy link
Owner

@nicowitteman Thanks for the feedback! Would you like to do a PR? If not I will update

Greetings Damien

@nicowitteman
Copy link
Author

I will leave it to you after you have reviewed the suggestions, if you don't mind.

@nicowitteman
Copy link
Author

I prepared a PR, waiting for merge of #56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants