From 0a97113c3502e7939540f43e9fbb38c0e6aa9ca0 Mon Sep 17 00:00:00 2001 From: Diana Tkachenko Date: Fri, 21 Jun 2019 00:51:48 -0700 Subject: [PATCH 1/3] fix auth regression --- src/providers/auth.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/providers/auth.ts b/src/providers/auth.ts index 708aca5ad..95747ede5 100644 --- a/src/providers/auth.ts +++ b/src/providers/auth.ts @@ -140,7 +140,10 @@ export function userRecordConstructor( _.set( record, 'metadata', - new UserRecordMetadata(meta.creationTime, meta.lastSignInTime) + new UserRecordMetadata( + meta.createdAt || meta.creationTime, + meta.lastSignedInAt || meta.lastSignInTime + ) ); } else { _.set(record, 'metadata', new UserRecordMetadata(null, null)); From 03edaa6e4fb78bf865f266584159137a15475893 Mon Sep 17 00:00:00 2001 From: Diana Tkachenko Date: Mon, 24 Jun 2019 10:40:29 -0700 Subject: [PATCH 2/3] adding unit and integration tests to test the wire format conversion for auth --- integration_test/functions/src/auth-tests.ts | 2 ++ spec/providers/auth.spec.ts | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/integration_test/functions/src/auth-tests.ts b/integration_test/functions/src/auth-tests.ts index 7b7f8686c..aaef21e6a 100644 --- a/integration_test/functions/src/auth-tests.ts +++ b/integration_test/functions/src/auth-tests.ts @@ -32,6 +32,8 @@ export const createUserTests: any = functions.auth.user().onCreate((u, c) => { expectEq((context as any).action, undefined) ) + .it('should have properly defined meta', (user, context) => user.metadata) + .run(testId, u, c); }); diff --git a/spec/providers/auth.spec.ts b/spec/providers/auth.spec.ts index 676e973ce..bee3435e0 100644 --- a/spec/providers/auth.spec.ts +++ b/spec/providers/auth.spec.ts @@ -178,6 +178,21 @@ describe('Auth Functions', () => { const record = auth.userRecordConstructor(raw); expect(record.toJSON()).to.deep.equal(raw); }); + + it('will convert raw wire fields createdAt and lastSignedInAt to creationTime and lastSignInTime', () => { + const raw: any = { + uid: '123', + metadata: { + createdAt: '2017-02-02T23:06:26.124Z', + lastSignedInAt: '2017-02-02T23:01:19.797Z', + }, + }; + const record = auth.userRecordConstructor(raw); + expect(record.metadata).to.deep.equal({ + creationTime: '2017-02-02T23:06:26.124Z', + lastSignInTime: '2017-02-02T23:01:19.797Z', + }); + }); }); describe('handler namespace', () => { From 420f40fec4354221b2a70b3f1ba02fb5de12cdc8 Mon Sep 17 00:00:00 2001 From: Diana Tkachenko Date: Mon, 24 Jun 2019 11:30:16 -0700 Subject: [PATCH 3/3] add changelog for release --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index e69de29bb..03f1fb9d3 100644 --- a/changelog.txt +++ b/changelog.txt @@ -0,0 +1 @@ +* Fixes bug where auth.UserRecord.metadata was undefined. \ No newline at end of file