@@ -57,6 +57,28 @@ type UserInfo struct {
57
57
UID string `json:"rawId,omitempty"`
58
58
}
59
59
60
+ // multiFactorInfoResponse describes the `mfaInfo` of the user record API response
61
+ type multiFactorInfoResponse struct {
62
+ MFAEnrollmentID string `json:"mfaEnrollmentId,omitempty"`
63
+ DisplayName string `json:"displayName,omitempty"`
64
+ PhoneInfo string `json:"phoneInfo,omitempty"`
65
+ EnrolledAt string `json:"enrolledAt,omitempty"`
66
+ }
67
+
68
+ // MultiFactorInfo describes a user enrolled second phone factor.
69
+ type MultiFactorInfo struct {
70
+ UID string
71
+ DisplayName string
72
+ EnrollmentTimestamp int64
73
+ FactorID string
74
+ PhoneNumber string
75
+ }
76
+
77
+ // MultiFactorSettings describes the multi-factor related user settings.
78
+ type MultiFactorSettings struct {
79
+ EnrolledFactors []* MultiFactorInfo
80
+ }
81
+
60
82
// UserMetadata contains additional metadata associated with a user account.
61
83
// Timestamps are in milliseconds since epoch.
62
84
type UserMetadata struct {
@@ -77,6 +99,7 @@ type UserRecord struct {
77
99
TokensValidAfterMillis int64 // milliseconds since epoch.
78
100
UserMetadata * UserMetadata
79
101
TenantID string
102
+ MultiFactor * MultiFactorSettings
80
103
}
81
104
82
105
// UserToCreate is the parameter struct for the CreateUser function.
@@ -892,23 +915,24 @@ func (c *baseClient) GetUsers(
892
915
}
893
916
894
917
type userQueryResponse struct {
895
- UID string `json:"localId,omitempty"`
896
- DisplayName string `json:"displayName,omitempty"`
897
- Email string `json:"email,omitempty"`
898
- PhoneNumber string `json:"phoneNumber,omitempty"`
899
- PhotoURL string `json:"photoUrl,omitempty"`
900
- CreationTimestamp int64 `json:"createdAt,string,omitempty"`
901
- LastLogInTimestamp int64 `json:"lastLoginAt,string,omitempty"`
902
- LastRefreshAt string `json:"lastRefreshAt,omitempty"`
903
- ProviderID string `json:"providerId,omitempty"`
904
- CustomAttributes string `json:"customAttributes,omitempty"`
905
- Disabled bool `json:"disabled,omitempty"`
906
- EmailVerified bool `json:"emailVerified,omitempty"`
907
- ProviderUserInfo []* UserInfo `json:"providerUserInfo,omitempty"`
908
- PasswordHash string `json:"passwordHash,omitempty"`
909
- PasswordSalt string `json:"salt,omitempty"`
910
- TenantID string `json:"tenantId,omitempty"`
911
- ValidSinceSeconds int64 `json:"validSince,string,omitempty"`
918
+ UID string `json:"localId,omitempty"`
919
+ DisplayName string `json:"displayName,omitempty"`
920
+ Email string `json:"email,omitempty"`
921
+ PhoneNumber string `json:"phoneNumber,omitempty"`
922
+ PhotoURL string `json:"photoUrl,omitempty"`
923
+ CreationTimestamp int64 `json:"createdAt,string,omitempty"`
924
+ LastLogInTimestamp int64 `json:"lastLoginAt,string,omitempty"`
925
+ LastRefreshAt string `json:"lastRefreshAt,omitempty"`
926
+ ProviderID string `json:"providerId,omitempty"`
927
+ CustomAttributes string `json:"customAttributes,omitempty"`
928
+ Disabled bool `json:"disabled,omitempty"`
929
+ EmailVerified bool `json:"emailVerified,omitempty"`
930
+ ProviderUserInfo []* UserInfo `json:"providerUserInfo,omitempty"`
931
+ PasswordHash string `json:"passwordHash,omitempty"`
932
+ PasswordSalt string `json:"salt,omitempty"`
933
+ TenantID string `json:"tenantId,omitempty"`
934
+ ValidSinceSeconds int64 `json:"validSince,string,omitempty"`
935
+ MFAInfo []* multiFactorInfoResponse `json:"mfaInfo,omitempty"`
912
936
}
913
937
914
938
func (r * userQueryResponse ) makeUserRecord () (* UserRecord , error ) {
@@ -948,6 +972,32 @@ func (r *userQueryResponse) makeExportedUserRecord() (*ExportedUserRecord, error
948
972
lastRefreshTimestamp = t .Unix () * 1000
949
973
}
950
974
975
+ // Map the MFA info to a slice of enrolled factors. Currently there is only
976
+ // support for PhoneMultiFactorInfo.
977
+ var enrolledFactors []* MultiFactorInfo
978
+ for _ , factor := range r .MFAInfo {
979
+ var enrollmentTimestamp int64
980
+ if factor .EnrolledAt != "" {
981
+ t , err := time .Parse (time .RFC3339 , factor .EnrolledAt )
982
+ if err != nil {
983
+ return nil , err
984
+ }
985
+ enrollmentTimestamp = t .Unix () * 1000
986
+ }
987
+
988
+ if factor .PhoneInfo == "" {
989
+ return nil , fmt .Errorf ("unsupported multi-factor auth response: %#v" , factor )
990
+ }
991
+
992
+ enrolledFactors = append (enrolledFactors , & MultiFactorInfo {
993
+ UID : factor .MFAEnrollmentID ,
994
+ DisplayName : factor .DisplayName ,
995
+ EnrollmentTimestamp : enrollmentTimestamp ,
996
+ FactorID : "phone" ,
997
+ PhoneNumber : factor .PhoneInfo ,
998
+ })
999
+ }
1000
+
951
1001
return & ExportedUserRecord {
952
1002
UserRecord : & UserRecord {
953
1003
UserInfo : & UserInfo {
@@ -969,6 +1019,9 @@ func (r *userQueryResponse) makeExportedUserRecord() (*ExportedUserRecord, error
969
1019
CreationTimestamp : r .CreationTimestamp ,
970
1020
LastRefreshTimestamp : lastRefreshTimestamp ,
971
1021
},
1022
+ MultiFactor : & MultiFactorSettings {
1023
+ EnrolledFactors : enrolledFactors ,
1024
+ },
972
1025
},
973
1026
PasswordHash : hash ,
974
1027
PasswordSalt : r .PasswordSalt ,
0 commit comments