FIX: handle null this.model when checking if component is for current user in CanCheckEmailsHelper (#30359)

This commit is contained in:
Kelv 2024-12-19 09:54:43 +08:00 committed by GitHub
parent 07efdaa32a
commit 74aeec8ea3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,6 +10,7 @@ export default class CanCheckEmailsHelper {
} }
get canCheckEmails() { get canCheckEmails() {
// Anonymous users can't check emails
if (!this.currentUser) { if (!this.currentUser) {
return false; return false;
} }
@ -17,7 +18,7 @@ export default class CanCheckEmailsHelper {
const canStaffCheckEmails = const canStaffCheckEmails =
this.can_moderators_view_emails && this.currentUser.staff; this.can_moderators_view_emails && this.currentUser.staff;
return ( return (
this.model.id === this.currentUser.id || this.model?.id === this.currentUser.id ||
this.canAdminCheckEmails || this.canAdminCheckEmails ||
canStaffCheckEmails canStaffCheckEmails
); );