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 {
143
143
144
144
// Metadata setter.
145
145
func (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
148
155
}
149
156
150
157
// CustomClaims setter.
Original file line number Diff line number Diff line change @@ -1184,6 +1184,24 @@ func TestUserToImport(t *testing.T) {
1184
1184
"lastLoginAt" : int64 (150 ),
1185
1185
},
1186
1186
},
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
+ },
1187
1205
{
1188
1206
user : (& UserToImport {}).UID ("test" ).PasswordHash ([]byte ("password" )),
1189
1207
want : map [string ]interface {}{
You can’t perform that action at this time.
0 commit comments