feat(core): add account deletion entry to account settings (#12385)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Implemented account deletion functionality with confirmation dialogs and success notifications.
  - Added a warning modal for team workspace owners before account deletion.
  - Introduced a new, richly formatted internationalized message for account deletion confirmation.
  - Added a new dialog component to inform users of successful account deletion.
- **Improvements**
  - Updated localization strings to provide detailed guidance and warnings for account deletion.
  - Enhanced error handling by converting errors into user-friendly notifications.
  - Simplified and improved the sign-out process with better error handling and streamlined navigation.
- **Style**
  - Added new style constants for success and warning modals related to account deletion.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
JimmFly
2025-05-27 08:00:44 +00:00
parent 18da2fe4e6
commit 8d3b20ecc7
15 changed files with 372 additions and 89 deletions

View File

@@ -101,6 +101,7 @@ import { DocCreatedByUpdatedBySyncService } from './services/doc-created-by-upda
import { WorkspacePermissionService } from '../permissions';
import { DocScope, DocService, DocsService } from '../doc';
import { DocCreatedByUpdatedBySyncStore } from './stores/doc-created-by-updated-by-sync';
import { GlobalDialogService } from '../dialogs';
export function configureCloudModule(framework: Framework) {
configureDefaultAuthProvider(framework);
@@ -123,7 +124,12 @@ export function configureCloudModule(framework: Framework) {
f.getOptional(ValidatorProvider)
);
})
.service(AuthService, [FetchService, AuthStore, UrlService])
.service(AuthService, [
FetchService,
AuthStore,
UrlService,
GlobalDialogService,
])
.store(AuthStore, [
FetchService,
GraphQLService,

View File

@@ -5,6 +5,7 @@ import { OnEvent, Service } from '@toeverything/infra';
import { nanoid } from 'nanoid';
import { distinctUntilChanged, map, skip } from 'rxjs';
import type { GlobalDialogService } from '../../dialogs';
import { ApplicationFocused } from '../../lifecycle';
import type { UrlService } from '../../url';
import { AuthSession } from '../entities/session';
@@ -23,7 +24,8 @@ export class AuthService extends Service {
constructor(
private readonly fetchService: FetchService,
private readonly store: AuthStore,
private readonly urlService: UrlService
private readonly urlService: UrlService,
private readonly dialogService: GlobalDialogService
) {
super();
@@ -189,6 +191,14 @@ export class AuthService extends Service {
this.session.revalidate();
}
async deleteAccount() {
const res = await this.store.deleteAccount();
this.store.setCachedAuthSession(null);
this.session.revalidate();
this.dialogService.open('deleted-account', {});
return res;
}
checkUserByEmail(email: string) {
return this.store.checkUserByEmail(email);
}

View File

@@ -1,4 +1,5 @@
import {
deleteAccountMutation,
removeAvatarMutation,
updateUserProfileMutation,
uploadAvatarMutation,
@@ -150,4 +151,11 @@ export class AuthStore extends Store {
return data;
}
async deleteAccount() {
const res = await this.gqlService.gql({
query: deleteAccountMutation,
});
return res.deleteAccount;
}
}

View File

@@ -37,6 +37,7 @@ export type GLOBAL_DIALOG_SCHEMA = {
openPageId?: string;
serverId?: string;
}) => boolean;
'deleted-account': () => void;
};
export type WORKSPACE_DIALOG_SCHEMA = {