diff --git a/src/auth/user-record.ts b/src/auth/user-record.ts index 6a825abe1c..2bd2fdacbd 100644 --- a/src/auth/user-record.ts +++ b/src/auth/user-record.ts @@ -337,6 +337,7 @@ export class UserMetadata { return { lastSignInTime: this.lastSignInTime, creationTime: this.creationTime, + lastRefreshTime: this.lastRefreshTime, }; } } diff --git a/test/integration/auth.spec.ts b/test/integration/auth.spec.ts index afd905a48d..78cfb62701 100644 --- a/test/integration/auth.spec.ts +++ b/test/integration/auth.spec.ts @@ -31,7 +31,7 @@ import { deepExtend, deepCopy } from '../../src/utils/deep-copy'; import { AuthProviderConfig, CreateTenantRequest, DeleteUsersResult, PhoneMultiFactorInfo, TenantAwareAuth, UpdatePhoneMultiFactorInfoRequest, UpdateTenantRequest, UserImportOptions, - UserImportRecord, UserRecord, getAuth, + UserImportRecord, UserMetadata, UserRecord, getAuth, } from '../../lib/auth/index'; const chalk = require('chalk'); // eslint-disable-line @typescript-eslint/no-var-requires @@ -2517,6 +2517,8 @@ describe('admin.auth', () => { metadata: { lastSignInTime: now, creationTime: now, + // TODO(rsgowman): Enable once importing users supports lastRefreshTime + //lastRefreshTime: now, }, providerData: [ { @@ -2548,6 +2550,11 @@ describe('admin.auth', () => { providerId: 'phone', phoneNumber: importUserRecord.phoneNumber!, }); + // The lastRefreshTime should be set to null + type Writable = { + -readonly [k in keyof UserMetadata]: UserMetadata[k]; + }; + (importUserRecord.metadata as Writable).lastRefreshTime = null; const actualUserRecord: {[key: string]: any} = userRecord.toJSON(); for (const key of Object.keys(importUserRecord)) { expect(JSON.stringify(actualUserRecord[key])) diff --git a/test/unit/auth/user-record.spec.ts b/test/unit/auth/user-record.spec.ts index cca0af6185..4ec43af305 100644 --- a/test/unit/auth/user-record.spec.ts +++ b/test/unit/auth/user-record.spec.ts @@ -83,6 +83,7 @@ function getValidUserResponse(tenantId?: string): GetAccountInfoUserResponse { validSince: '1476136676', lastLoginAt: '1476235905000', createdAt: '1476136676000', + lastRefreshAt: '2016-10-12T01:31:45.000Z', customAttributes: JSON.stringify({ admin: true, }), @@ -159,6 +160,7 @@ function getUserJSON(tenantId?: string): object { metadata: { lastSignInTime: new Date(1476235905000).toUTCString(), creationTime: new Date(1476136676000).toUTCString(), + lastRefreshTime: new Date(1476235905000).toUTCString(), }, customClaims: { admin: true, @@ -629,6 +631,7 @@ describe('UserMetadata', () => { const expectedMetadataJSON = { lastSignInTime: new Date(expectedLastLoginAt).toUTCString(), creationTime: new Date(expectedCreatedAt).toUTCString(), + lastRefreshTime: new Date(expectedLastRefreshAt).toUTCString(), }; describe('constructor', () => { @@ -890,6 +893,7 @@ describe('UserRecord', () => { const metadata = new UserMetadata({ createdAt: '1476136676000', lastLoginAt: '1476235905000', + lastRefreshAt: '2016-10-12T01:31:45.000Z', } as any); expect(userRecord.metadata).to.deep.equal(metadata); });