Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix bug where auth metadata in the auth blocking tokens are assumed t…
…o be seconds not miliseconds.
  • Loading branch information
taeold committed Oct 17, 2023
commit d738a4afe25ad7c3235c9b4018d1d7b961d03b17
12 changes: 6 additions & 6 deletions spec/common/providers/identity.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ describe("identity", () => {

describe("parseMetadata", () => {
const decodedMetadata = {
last_sign_in_time: 1476235905,
creation_time: 1476136676,
last_sign_in_time: 1476235905000,
creation_time: 1476136676000,
};
const metadata = {
lastSignInTime: new Date(1476235905000).toUTCString(),
Expand Down Expand Up @@ -374,8 +374,8 @@ describe("identity", () => {
photo_url: "https://lh3.googleusercontent.com/1234567890/photo.jpg",
tokens_valid_after_time: 1476136676,
metadata: {
last_sign_in_time: 1476235905,
creation_time: 1476136676,
last_sign_in_time: 1476235905000,
creation_time: 1476136676000,
},
custom_claims: {
admin: true,
Expand Down Expand Up @@ -632,8 +632,8 @@ describe("identity", () => {
photo_url: "https://lh3.googleusercontent.com/1234567890/photo.jpg",
tokens_valid_after_time: 1476136676,
metadata: {
last_sign_in_time: 1476235905,
creation_time: 1476136676,
last_sign_in_time: 1476235905000,
creation_time: 1476136676000,
},
custom_claims: {
admin: true,
Expand Down
4 changes: 2 additions & 2 deletions src/common/providers/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,10 @@ function unsafeDecodeAuthBlockingToken(token: string): DecodedPayload {
*/
export function parseMetadata(metadata: DecodedPayloadUserRecordMetadata): AuthUserMetadata {
const creationTime = metadata?.creation_time
? new Date(metadata.creation_time * 1000).toUTCString()
? new Date(metadata.creation_time).toUTCString()
: null;
const lastSignInTime = metadata?.last_sign_in_time
? new Date(metadata.last_sign_in_time * 1000).toUTCString()
? new Date(metadata.last_sign_in_time).toUTCString()
: null;
return {
creationTime,
Expand Down