mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix(auth): update logic after deleting an org
1. Redirect to organizations list if the user has orgs 2. Clear organization from preferences so the deleted org isn't the default and they aren't redirected to it 3. Invalidate after redirect so there isn't a flash or invalid org/team
This commit is contained in:
1 file changed
+7
-12
+7
-12
@@ -24,22 +24,17 @@
|
||||
} else {
|
||||
await sdk.forConsole.teams.delete($organization.$id);
|
||||
}
|
||||
|
||||
await invalidate(Dependencies.ACCOUNT);
|
||||
await invalidate(Dependencies.ORGANIZATION);
|
||||
trackEvent(Submit.OrganizationDelete);
|
||||
const prefs = await sdk.forConsole.account.getPrefs();
|
||||
const newPrefs = { ...prefs, organization: null };
|
||||
await sdk.forConsole.account.updatePrefs(newPrefs);
|
||||
if ($organizationList?.total > 1) {
|
||||
const account = await sdk.forConsole.account.get();
|
||||
const teamId =
|
||||
account.prefs.organization ??
|
||||
$organizationList.teams[0].$id === $organization.$id
|
||||
? $organizationList.teams[1].$id
|
||||
: $organizationList.teams[0].$id;
|
||||
|
||||
await goto(`${base}/console/organization-${teamId}`);
|
||||
await goto(`${base}/console/account/organizations`);
|
||||
} else {
|
||||
await goto(`${base}/console/onboarding`);
|
||||
}
|
||||
await invalidate(Dependencies.ACCOUNT);
|
||||
await invalidate(Dependencies.ORGANIZATION);
|
||||
trackEvent(Submit.OrganizationDelete);
|
||||
showDelete = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
|
||||
Reference in new issue
Block a user