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

Feature request: Add dynamic post logout redirect urls #76

Closed
3 tasks done
DaveOrDead opened this issue Oct 30, 2023 · 1 comment
Closed
3 tasks done

Feature request: Add dynamic post logout redirect urls #76

DaveOrDead opened this issue Oct 30, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@DaveOrDead
Copy link
Member

Prerequisites

What is the problem you’re trying to solve?

In the same way that dynamic post login urls are allowed, it would be useful to allow the same for logout.

For example to allow both:

api/auth/logout?post_logout_redirect_uri=product1/login
api/auth/logout?post_logout_redirect_uri=product2/login

What solution would you like to see?

a post_logout_redirect_uri parameter that can be passed to the logout url something like

<Link
    href={{
        pathname: "/api/auth/logout",
        query: {
            post_logout_redirect_url: "/product2/login"
        }
    }}
>
    Log out
</Link>

Additional information

No response

@DaveOrDead DaveOrDead added the enhancement New feature or request label Oct 30, 2023
@bliongosari1
Copy link

bliongosari1 commented Nov 6, 2023

export const logout = async (routerClient) => {
const authUrl = await routerClient.kindeClient.logout(
routerClient.sessionManager,
{
authUrlParams: Object.fromEntries(routerClient.searchParams)
}
);

const postLogoutRedirectURL = routerClient.getSearchParam(
'post_logout_redirect_url'
);

if (postLogoutRedirectURL) {
await routerClient.sessionManager.setSessionItem(
'post_logout_redirect_url',
postLogoutRedirectURL
);
}

routerClient.redirect(authUrl);
};

Think this should do it for pages router, just need to add LogoutLink for app router

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

3 participants