From 74aeec8ea3df4b340832346682dea414bc2258d1 Mon Sep 17 00:00:00 2001 From: Kelv Date: Thu, 19 Dec 2024 09:54:43 +0800 Subject: [PATCH] FIX: handle null this.model when checking if component is for current user in CanCheckEmailsHelper (#30359) --- .../javascripts/discourse/app/lib/can-check-emails-helper.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/lib/can-check-emails-helper.js b/app/assets/javascripts/discourse/app/lib/can-check-emails-helper.js index 91be0e897e2..656cbe66cd9 100644 --- a/app/assets/javascripts/discourse/app/lib/can-check-emails-helper.js +++ b/app/assets/javascripts/discourse/app/lib/can-check-emails-helper.js @@ -10,6 +10,7 @@ export default class CanCheckEmailsHelper { } get canCheckEmails() { + // Anonymous users can't check emails if (!this.currentUser) { return false; } @@ -17,7 +18,7 @@ export default class CanCheckEmailsHelper { const canStaffCheckEmails = this.can_moderators_view_emails && this.currentUser.staff; return ( - this.model.id === this.currentUser.id || + this.model?.id === this.currentUser.id || this.canAdminCheckEmails || canStaffCheckEmails );