Firebase Custom Authentication - lastSignInTime = Null

Viewed 210

I'm using 'firebase-admin' for node to create custom tokens based on users created using admin.auth().createUser(params) and updated via admin.auth().updateUser(userId, updateParams)

However, when a custom user is created, such user's "signed in" field is "null" in the Firebase Authentication Dashboard as well as when I fetch user record using admin.auth().getUser('custom:uid').then((userRecord) => { console.log(userRecord.toJSON()); })

Below is the result from fetching user record (I have masked credentials):

{ uid: 'custom:uid', email: 'xxx@yyy.com', emailVerified: false, displayName: 'testuser', photoURL: 'https://xxxx.jpg', phoneNumber: undefined, disabled: false, metadata: { lastSignInTime: null, creationTime: 'Mon, 29 Mar 2021 08:11:56 GMT' }, passwordHash: undefined, passwordSalt: undefined, customClaims: undefined, tokensValidAfterTime: 'Mon, 29 Mar 2021 08:11:56 GMT', tenantId: undefined, providerData: [] }

and below is my dashboard screenshot: enter image description here

My question is what should I do to update 'lastSignInTime', so that it correctly updates upon a user sign in? I assumed that either when I createUser() or updateUser(), Firebase shall automatically record the "Signed In" field (as it did for "Created"), which it did not do.

1 Answers

The value of "Signed In" will update when the user signs in for the first time. As far as I'm aware there's no other way to update that value.

Related