Skip to content

Commit

Permalink
fix(auth, android): do not timezone offset when getting UTC timestamp (
Browse files Browse the repository at this point in the history
…#4886)

* Add test for expirationTime of tokenResult
* Fix android timestampToUTC util
* Use single quote
  • Loading branch information
kouheiszk authored Feb 9, 2021
1 parent c832407 commit 85d6801
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,10 @@ public static WritableMap getExceptionMap(Exception exception) {
}

public static String timestampToUTC(long timestamp) {
Calendar calendar = Calendar.getInstance();
long millisTimestamp = timestamp * 1000;
Date date = new Date(millisTimestamp + calendar.getTimeZone().getOffset(millisTimestamp));
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
format.setTimeZone(TimeZone.getTimeZone("UTC"));
return format.format(date);
return format.format(millisTimestamp);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions packages/auth/e2e/user.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ describe('auth().currentUser', function () {

tokenResult.claims.should.be.a.Object();
tokenResult.claims.iat.should.be.a.Number();
tokenResult.claims.exp.should.be.a.Number();
tokenResult.claims.iss.should.be.a.String();

new Date(tokenResult.issuedAtTime).getTime().should.equal(tokenResult.claims.iat * 1000);
new Date(tokenResult.expirationTime).getTime().should.equal(tokenResult.claims.exp * 1000);

tokenResult.signInProvider.should.equal('password');
tokenResult.token.length.should.be.greaterThan(24);

Expand Down

1 comment on commit 85d6801

@vercel
Copy link

@vercel vercel bot commented on 85d6801 Feb 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.