File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -143,8 +143,15 @@ func (u *UserToImport) PhoneNumber(phoneNumber string) *UserToImport {
143143
144144// Metadata setter.
145145func (u * UserToImport ) Metadata (metadata * UserMetadata ) * UserToImport {
146- u .set ("createdAt" , metadata .CreationTimestamp )
147- return u .set ("lastLoginAt" , metadata .LastLogInTimestamp )
146+ if metadata .CreationTimestamp != 0 {
147+ u .set ("createdAt" , metadata .CreationTimestamp )
148+ }
149+
150+ if metadata .LastLogInTimestamp != 0 {
151+ u .set ("lastLoginAt" , metadata .LastLogInTimestamp )
152+ }
153+
154+ return u
148155}
149156
150157// CustomClaims setter.
Original file line number Diff line number Diff line change @@ -1184,6 +1184,24 @@ func TestUserToImport(t *testing.T) {
11841184 "lastLoginAt" : int64 (150 ),
11851185 },
11861186 },
1187+ {
1188+ user : (& UserToImport {}).UID ("test" ).Metadata (& UserMetadata {
1189+ CreationTimestamp : int64 (100 ),
1190+ }),
1191+ want : map [string ]interface {}{
1192+ "localId" : "test" ,
1193+ "createdAt" : int64 (100 ),
1194+ },
1195+ },
1196+ {
1197+ user : (& UserToImport {}).UID ("test" ).Metadata (& UserMetadata {
1198+ LastLogInTimestamp : int64 (150 ),
1199+ }),
1200+ want : map [string ]interface {}{
1201+ "localId" : "test" ,
1202+ "lastLoginAt" : int64 (150 ),
1203+ },
1204+ },
11871205 {
11881206 user : (& UserToImport {}).UID ("test" ).PasswordHash ([]byte ("password" )),
11891207 want : map [string ]interface {}{
You can’t perform that action at this time.
0 commit comments