Skip to content

Commit eacce1a

Browse files
committed
Add lastRefreshTime to UserMetadata toJSON method.
See #887
1 parent 4d5c216 commit eacce1a

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/auth/user-record.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ export class UserMetadata {
335335
return {
336336
lastSignInTime: this.lastSignInTime,
337337
creationTime: this.creationTime,
338+
lastRefreshTime: this.lastRefreshTime,
338339
};
339340
}
340341
}

test/integration/auth.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,6 +1802,7 @@ describe('admin.auth', () => {
18021802
metadata: {
18031803
lastSignInTime: now,
18041804
creationTime: now,
1805+
lastRefreshTime: null, // TODO(rsgowman): Switch to 'now' once importing users supports lastRefreshTime
18051806
},
18061807
providerData: [
18071808
{

test/unit/auth/user-record.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ function getValidUserResponse(tenantId?: string): GetAccountInfoUserResponse {
8080
validSince: '1476136676',
8181
lastLoginAt: '1476235905000',
8282
createdAt: '1476136676000',
83+
lastRefreshAt: '2016-10-12T01:31:45.000Z',
8384
customAttributes: JSON.stringify({
8485
admin: true,
8586
}),
@@ -156,6 +157,7 @@ function getUserJSON(tenantId?: string): object {
156157
metadata: {
157158
lastSignInTime: new Date(1476235905000).toUTCString(),
158159
creationTime: new Date(1476136676000).toUTCString(),
160+
lastRefreshTime: new Date(1476235905000).toUTCString(),
159161
},
160162
customClaims: {
161163
admin: true,
@@ -616,14 +618,17 @@ describe('UserInfo', () => {
616618
describe('UserMetadata', () => {
617619
const expectedLastLoginAt = 1476235905000;
618620
const expectedCreatedAt = 1476136676000;
621+
const expectedLastRefreshAt = '2016-10-12T01:31:45.000Z';
619622
const actualMetadata: UserMetadata = new UserMetadata({
620623
localId: 'uid123',
621624
lastLoginAt: expectedLastLoginAt.toString(),
622625
createdAt: expectedCreatedAt.toString(),
626+
lastRefreshAt: expectedLastRefreshAt,
623627
});
624628
const expectedMetadataJSON = {
625629
lastSignInTime: new Date(expectedLastLoginAt).toUTCString(),
626630
creationTime: new Date(expectedCreatedAt).toUTCString(),
631+
lastRefreshTime: new Date(expectedLastRefreshAt).toUTCString(),
627632
};
628633

629634
describe('constructor', () => {
@@ -872,6 +877,7 @@ describe('UserRecord', () => {
872877
const metadata = new UserMetadata({
873878
createdAt: '1476136676000',
874879
lastLoginAt: '1476235905000',
880+
lastRefreshAt: '2016-10-12T01:31:45.000Z',
875881
} as any);
876882
expect(userRecord.metadata).to.deep.equal(metadata);
877883
});

0 commit comments

Comments
 (0)