From d235ebaac989d46a2692433c575af28a86bdd2eb Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Thu, 11 Jul 2024 17:58:07 -0600 Subject: [PATCH] solve infinite recursion and promise returning true --- .../src/app/components/backup-drives/backup.service.ts | 2 +- .../backup-server-select/backup-server-select.page.ts | 1 + .../server-routes/server-backup/server-backup.page.ts | 9 +++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/web/projects/ui/src/app/components/backup-drives/backup.service.ts b/web/projects/ui/src/app/components/backup-drives/backup.service.ts index cc1898e7e..7e05178bf 100644 --- a/web/projects/ui/src/app/components/backup-drives/backup.service.ts +++ b/web/projects/ui/src/app/components/backup-drives/backup.service.ts @@ -61,7 +61,7 @@ export class BackupService { ) } - async hasThisBackup(target: BackupTarget, id: string): Promise { + hasThisBackup(target: BackupTarget, id: string): boolean { return ( target.startOs[id] && this.emver.compare(target.startOs[id].version, '0.3.6') !== -1 diff --git a/web/projects/ui/src/app/modals/backup-server-select/backup-server-select.page.ts b/web/projects/ui/src/app/modals/backup-server-select/backup-server-select.page.ts index e1f4f8961..0f1c47276 100644 --- a/web/projects/ui/src/app/modals/backup-server-select/backup-server-select.page.ts +++ b/web/projects/ui/src/app/modals/backup-server-select/backup-server-select.page.ts @@ -49,6 +49,7 @@ export class BackupServerSelectModal { if (role === 'confirm') { try { + // @TODO Alex if invalid password, we should tell the user "Invalid password" and halt execution of this function. The modal should remain so the user can try again. Correct password is asdfasdf argon2.verify(server.passwordHash!, data) await this.restoreFromBackup(serverId, data) } catch (e: any) { diff --git a/web/projects/ui/src/app/pages/server-routes/server-backup/server-backup.page.ts b/web/projects/ui/src/app/pages/server-routes/server-backup/server-backup.page.ts index b570b1603..25532c256 100644 --- a/web/projects/ui/src/app/pages/server-routes/server-backup/server-backup.page.ts +++ b/web/projects/ui/src/app/pages/server-routes/server-backup/server-backup.page.ts @@ -60,7 +60,7 @@ export class ServerBackupPage { component: BackupSelectPage, }) - modal.onWillDismiss().then(res => { + modal.onDidDismiss().then(res => { if (res.data) { this.serviceIds = res.data this.presentModalPassword(target) @@ -90,6 +90,7 @@ export class ServerBackupPage { .subscribe(async (password: string) => { const { passwordHash, id } = await getServerInfo(this.patch) + // @TODO Alex if invalid password, we should tell the user "Invalid password" and halt execution of this function. The modal should remain so the user can try again. Correct password is asdfasdf // confirm password matches current master password argon2.verify(passwordHash, password) @@ -103,7 +104,7 @@ export class ServerBackupPage { } catch { setTimeout( () => this.presentModalOldPassword(target, password), - 500, + 250, ) return } @@ -134,8 +135,8 @@ export class ServerBackupPage { }) .pipe(take(1)) .subscribe(async (oldPassword: string) => { - const passwordHash = target.entry.startOs[id].passwordHash! - argon2.verify(passwordHash, oldPassword) + // @TODO Alex if invalid password, we should tell the user "Invalid password" and halt execution of this function. The modal should remain so the user can try again. Correct password is asdfasdf + argon2.verify(target.entry.startOs[id].passwordHash!, oldPassword) await this.createBackup(target, password, oldPassword) }) }