mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-06-19 01:46:27 +08:00
fix(auth): user.metadata uses ISO strings (#3360)
* fix(auth): user.metadata uses ISO strings * chore(auth): move code to metadata getter * chore(auth): refactor user.metadata * test(auth): metadata props are milliseconds
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -551,6 +551,7 @@ GoogleService-Info.plist
|
||||
# generated file
|
||||
RNFBVersion.m
|
||||
|
||||
appPlaygrounds/
|
||||
app.playground.js
|
||||
app.admob.js
|
||||
app.smartreply.js
|
||||
|
||||
@@ -396,4 +396,23 @@ describe('auth().currentUser', () => {
|
||||
await firebase.auth().signOut();
|
||||
});
|
||||
});
|
||||
|
||||
describe('user.metadata', () => {
|
||||
it("should have the properties 'lastSignInTime' & 'creationTime' which are ISO strings", async () => {
|
||||
const random = Utils.randString(12, '#aA');
|
||||
const email = `${random}@${random}.com`;
|
||||
|
||||
const { user } = await firebase.auth().createUserWithEmailAndPassword(email, random);
|
||||
|
||||
const { metadata } = user;
|
||||
|
||||
should(metadata.lastSignInTime).be.a.String();
|
||||
should(metadata.creationTime).be.a.String();
|
||||
|
||||
new Date(metadata.lastSignInTime).getFullYear().should.equal(new Date().getFullYear());
|
||||
new Date(metadata.creationTime).getFullYear().should.equal(new Date().getFullYear());
|
||||
|
||||
await firebase.auth().currentUser.delete();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -40,7 +40,12 @@ export default class User {
|
||||
}
|
||||
|
||||
get metadata() {
|
||||
return this._user.metadata;
|
||||
const { metadata } = this._user;
|
||||
|
||||
return {
|
||||
lastSignInTime: new Date(metadata.lastSignInTime).toISOString(),
|
||||
creationTime: new Date(metadata.creationTime).toISOString(),
|
||||
};
|
||||
}
|
||||
|
||||
get phoneNumber() {
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
require('./app');
|
||||
// require('./app.playground');
|
||||
// require('./appPlaygrounds/firestore');
|
||||
//require('./app.admob');
|
||||
|
||||
Reference in New Issue
Block a user