From fb5eb1a47b3cb8a20948dd81e0b3cde58e4e912b Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Tue, 12 Jan 2021 16:02:44 +0000 Subject: [PATCH] Server: Dismiss admin password notification when password has been changed --- packages/server/src/middleware/notificationHandler.ts | 2 ++ packages/server/src/models/NotificationModel.ts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/packages/server/src/middleware/notificationHandler.ts b/packages/server/src/middleware/notificationHandler.ts index 8582fabe4..d5ec2e552 100644 --- a/packages/server/src/middleware/notificationHandler.ts +++ b/packages/server/src/middleware/notificationHandler.ts @@ -27,6 +27,8 @@ export default async function(ctx: AppContext, next: KoaNext): Promise { NotificationLevel.Important, _('The default admin password is insecure and has not been changed! [Change it now](%s)', await ctx.models.user().profileUrl()) ); + } else { + await notificationModel.markAsRead('change_admin_password'); } } diff --git a/packages/server/src/models/NotificationModel.ts b/packages/server/src/models/NotificationModel.ts index ee2b57d5e..237542d52 100644 --- a/packages/server/src/models/NotificationModel.ts +++ b/packages/server/src/models/NotificationModel.ts @@ -14,6 +14,9 @@ export default class NotificationModel extends BaseModel { } public async markAsRead(key: string): Promise { + const n = await this.loadByKey(key); + if (!n) return; + await this.db(this.tableName) .update({ read: 1 }) .where('key', '=', key)