fix: cookie issues in Electron (#4115)

This commit is contained in:
Peng Xiao
2023-09-02 01:34:08 +08:00
committed by GitHub
parent 3c4f45bcb6
commit c9c76983de
6 changed files with 95 additions and 31 deletions

View File

@@ -17,26 +17,30 @@ export const signInCloud: typeof signIn = async (provider, ...rest) => {
'_target'
);
return;
} else if (provider === 'email') {
} else {
const [options, ...tail] = rest;
const callbackUrl =
runtimeConfig.serverUrlPrefix +
(provider === 'email' ? '/open-app/oauth-jwt' : location.pathname);
return signIn(
provider,
{
...options,
callbackUrl: buildCallbackUrl('/open-app/oauth-jwt'),
callbackUrl: buildCallbackUrl(callbackUrl),
},
...tail
);
} else {
throw new Error('Unsupported provider');
}
} else {
return signIn(provider, ...rest);
}
};
export const signOutCloud: typeof signOut = async (...args) => {
return signOut(...args).then(result => {
export const signOutCloud: typeof signOut = async options => {
return signOut({
...options,
callbackUrl: '/',
}).then(result => {
if (result) {
startTransition(() => {
getCurrentStore().set(refreshRootMetadataAtom);