diff --git a/src/abstractions/token.service.ts b/src/abstractions/token.service.ts index 939b96f90f..dbc446a41d 100644 --- a/src/abstractions/token.service.ts +++ b/src/abstractions/token.service.ts @@ -17,6 +17,7 @@ export abstract class TokenService { tokenNeedsRefresh: (minutes?: number) => boolean; getUserId: () => string; getEmail: () => string; + getEmailVerified: () => boolean; getName: () => string; getPremium: () => boolean; getIssuer: () => string; diff --git a/src/services/token.service.ts b/src/services/token.service.ts index c572621103..1540d1a0ef 100644 --- a/src/services/token.service.ts +++ b/src/services/token.service.ts @@ -148,6 +148,15 @@ export class TokenService implements TokenServiceAbstraction { return decoded.email as string; } + getEmailVerified(): boolean { + const decoded = this.decodeToken(); + if (typeof decoded.email_verified === 'undefined') { + throw new Error('No email verification found'); + } + + return decoded.email_verified as boolean; + } + getName(): string { const decoded = this.decodeToken(); if (typeof decoded.name === 'undefined') {