简体   繁体   English

登录后重定向到指定页面 - keycloak

[英]redirecting to specified page, after login - keycloak

I'm clicking on url which is redirecting me to some page on my website.我正在点击 url,它会将我重定向到我网站上的某个页面。 Everything works fine until user is not logged in. How to redirect someone to url which I clicked after login?一切正常,直到用户未登录。如何将某人重定向到我在登录后单击的 url? is there way to store this url or something?有没有办法存储这个 url 之类的东西?

I've tried so hard and get so far but in the end it doesnt really matters我已经很努力地做到了,但最终这并不重要

You can use .redirectUri to set the redirect URL. Make sure the URL is also set in Valid redirect URIs of client.您可以使用.redirectUri设置重定向 URL。确保 URL 也已在客户端的Valid redirect URIs中设置。

const Login = (onAuthenticatedCallback) => {
    keycloakInstance
        .init({
            ...
        })
        .then(function (authenticated) {
            if (authenticated) {
                ...

                keycloakInstance.redirectUri = window.location.origin + "/HomePage"
            } else {
                alert("non authenticated")
            }
        })
        .catch((e) => {
            console.log(`keycloak init exception: ${e}`);
        });
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM