From 8be95bfe574a7ae2c8173921bbdfe82451436081 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 2 Jul 2018 10:27:27 -0400 Subject: [PATCH] get email verified from token service --- src/abstractions/token.service.ts | 1 + src/services/token.service.ts | 9 +++++++++ 2 files changed, 10 insertions(+) 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') {