admin管理员组文章数量:1122832
I’m working on a SvelteKit app using Supabase, Auth.js, and a HubSpot OAuth integration. I want to disconnect the HubSpot OAuth connection when a new user logs in (normal logins are handled by supabase). However, when I try to call signOut
(to disconnect HubSpot) during the login process, it interferes with the login redirect.
Here’s my current code:
const onLogin = async (event: SubmitEvent) => {
event.preventDefault();
const form = event.currentTarget as HTMLFormElement;
const data = new FormData(form);
$loginQuery.mutate(data, {
onSuccess: async () => {
createToast({
message: "Logged in",
type: 'info'
});
// Attempt to disconnect OAuth after login
await signOut({ redirect: undefined });
},
onError: (error) => {
createToast({
message: error.message || "Failed to log in, check your info!",
type: 'error'
});
}
});
};
Problem:
- If I call
signOut
right after the login mutation (outside theonSuccess
), it interferes with the redirect and breaks the login process. The user just stays on the Login page and has to login in a second time. Then it works (because the OAuth was disconnected). - If I move the
signOut
call into theonSuccess
callback and make itasync
, it does nothing—the HubSpot connection remains active.
What I’ve Tried:
- Calling
signOut
asynchronously in theonSuccess
callback. - Delaying the redirect until after the
signOut
completes. - Explicitly passing
{ redirect: false }
tosignOut
.
None of these approaches have worked. The signOut
either doesn’t execute as expected or conflicts with the redirect.
Question:
- Is there another way to disconnect the HubSpot OAuth session using Auth.js that avoids this conflict?
- How can I reliably disconnect the HubSpot OAuth session after a new user logs in without breaking the login flow or the redirect?
Tech Stack:
- SvelteKit
- Supabase
- Hooks for redirects
- Auth.js
- HubSpot OAuth
本文标签: typescriptDisconnecting OAuth connection in the backgroundStack Overflow
版权声明:本文标题:typescript - Disconnecting OAuth connection in the background - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736310738a1934487.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论