Move sign out command before account deletion and modify private path prefixes

The sign out command is moved ahead of the account deletion service to ensure users are logged out before their account gets deleted. The "/join" prefix is removed from the list of private path prefixes. Additionally, a global loader component is added to the join loading page.
This commit is contained in:
giancarlo
2024-04-28 21:00:41 +07:00
parent 4390f64b8a
commit 1009685efd
3 changed files with 7 additions and 4 deletions

View File

@@ -0,0 +1,3 @@
import { GlobalLoader } from '@kit/ui/global-loader';
export default GlobalLoader;

View File

@@ -37,6 +37,9 @@ export const deletePersonalAccountAction = enhanceAction(
// create a new instance of the personal accounts service
const service = createDeletePersonalAccountService();
// sign out the user before deleting their account
await client.auth.signOut();
// delete the user's account and cancel all subscriptions
await service.deletePersonalAccount({
adminClient: getSupabaseServerActionClient({ admin: true }),
@@ -45,9 +48,6 @@ export const deletePersonalAccountAction = enhanceAction(
emailSettings,
});
// sign out the user after deleting their account
await client.auth.signOut();
// clear the cache for all pages
revalidatePath('/', 'layout');

View File

@@ -11,7 +11,7 @@ import { useRevalidateUserSession, useUserSession } from './use-user-session';
* @name PRIVATE_PATH_PREFIXES
* @description A list of private path prefixes
*/
const PRIVATE_PATH_PREFIXES = ['/home', '/admin', '/join', '/update-password'];
const PRIVATE_PATH_PREFIXES = ['/home', '/admin', '/update-password'];
/**
* @name useAuthChangeListener