fix: Bug - Add logout in mobile version of settings, allow clearing data on android
All checks were successful
Queue Release Build / prepare (push) Successful in 19s
Deploy Web Apps / deploy (push) Successful in 7m55s
Queue Release Build / build-windows (push) Successful in 28m37s
Queue Release Build / build-linux (push) Successful in 47m3s
Queue Release Build / build-android (push) Successful in 20m33s
Queue Release Build / finalize (push) Successful in 3m48s
All checks were successful
Queue Release Build / prepare (push) Successful in 19s
Deploy Web Apps / deploy (push) Successful in 7m55s
Queue Release Build / build-windows (push) Successful in 28m37s
Queue Release Build / build-linux (push) Successful in 47m3s
Queue Release Build / build-android (push) Successful in 20m33s
Queue Release Build / finalize (push) Successful in 3m48s
Expose settings logout on mobile where the title bar is hidden, and enable Capacitor data settings with storage visibility and local erase/sign-out. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
|
||||
import { PlatformService } from '../../core/platform';
|
||||
import { clearStoredLocalAppData } from '../../core/storage/current-user-storage';
|
||||
import { DatabaseService } from './database.service';
|
||||
import { UserLogoutService } from '../../domains/authentication/application/services/user-logout.service';
|
||||
import { AuthTokenStoreService } from '../../domains/authentication/application/services/auth-token-store.service';
|
||||
import { loadCapacitorAttachmentFilesystem } from '../../domains/attachment/infrastructure/services/capacitor-attachment-filesystem.adapter';
|
||||
|
||||
const CAPACITOR_APP_DATA_ROOT = 'metoyou';
|
||||
|
||||
export interface EraseLocalUserDataResult {
|
||||
restartRequired: boolean;
|
||||
}
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class LocalUserDataService {
|
||||
private readonly platform = inject(PlatformService);
|
||||
private readonly database = inject(DatabaseService);
|
||||
private readonly userLogout = inject(UserLogoutService);
|
||||
private readonly authTokenStore = inject(AuthTokenStoreService);
|
||||
|
||||
async eraseLocalUserData(): Promise<EraseLocalUserDataResult> {
|
||||
if (!this.platform.isCapacitor) {
|
||||
throw new Error('Local user data erase is only supported on native mobile shells.');
|
||||
}
|
||||
|
||||
await this.database.clearAllData();
|
||||
await this.deleteCapacitorAttachmentTree();
|
||||
this.authTokenStore.clearAllTokens();
|
||||
clearStoredLocalAppData();
|
||||
this.userLogout.logout();
|
||||
|
||||
return { restartRequired: false };
|
||||
}
|
||||
|
||||
private async deleteCapacitorAttachmentTree(): Promise<void> {
|
||||
const filesystem = await loadCapacitorAttachmentFilesystem();
|
||||
|
||||
if (!filesystem) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await filesystem.filesystem.rmdir({
|
||||
path: CAPACITOR_APP_DATA_ROOT,
|
||||
directory: filesystem.directory,
|
||||
recursive: true
|
||||
});
|
||||
} catch {
|
||||
// Missing directory is fine during erase.
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user