@@ -57,6 +57,37 @@ 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
+ // MultiFactorID represents the type of an enrolled factor, for now only Phone
69
+ // is available.
70
+ type MultiFactorID string
71
+
72
+ const (
73
+ // Phone represents an enrolled factor of type Phone / SMS
74
+ Phone MultiFactorID = "phone"
75
+ )
76
+
77
+ // MultiFactorInfo describes a user enrolled second phone factor.
78
+ type MultiFactorInfo struct {
79
+ UID string
80
+ DisplayName string
81
+ EnrollmentTimestamp int64
82
+ FactorID MultiFactorID
83
+ PhoneNumber string
84
+ }
85
+
86
+ // MultiFactorSettings describes the multi-factor related user settings.
87
+ type MultiFactorSettings struct {
88
+ EnrolledFactors []* MultiFactorInfo
89
+ }
90
+
60
91
// UserMetadata contains additional metadata associated with a user account.
61
92
// Timestamps are in milliseconds since epoch.
62
93
type UserMetadata struct {
@@ -77,6 +108,7 @@ type UserRecord struct {
77
108
TokensValidAfterMillis int64 // milliseconds since epoch.
78
109
UserMetadata * UserMetadata
79
110
TenantID string
111
+ MultiFactor * MultiFactorSettings
80
112
}
81
113
82
114
// UserToCreate is the parameter struct for the CreateUser function.
@@ -892,23 +924,24 @@ func (c *baseClient) GetUsers(
892
924
}
893
925
894
926
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"`
927
+ UID string `json:"localId,omitempty"`
928
+ DisplayName string `json:"displayName,omitempty"`
929
+ Email string `json:"email,omitempty"`
930
+ PhoneNumber string `json:"phoneNumber,omitempty"`
931
+ PhotoURL string `json:"photoUrl,omitempty"`
932
+ CreationTimestamp int64 `json:"createdAt,string,omitempty"`
933
+ LastLogInTimestamp int64 `json:"lastLoginAt,string,omitempty"`
934
+ LastRefreshAt string `json:"lastRefreshAt,omitempty"`
935
+ ProviderID string `json:"providerId,omitempty"`
936
+ CustomAttributes string `json:"customAttributes,omitempty"`
937
+ Disabled bool `json:"disabled,omitempty"`
938
+ EmailVerified bool `json:"emailVerified,omitempty"`
939
+ ProviderUserInfo []* UserInfo `json:"providerUserInfo,omitempty"`
940
+ PasswordHash string `json:"passwordHash,omitempty"`
941
+ PasswordSalt string `json:"salt,omitempty"`
942
+ TenantID string `json:"tenantId,omitempty"`
943
+ ValidSinceSeconds int64 `json:"validSince,string,omitempty"`
944
+ MFAInfo []* multiFactorInfoResponse `json:"mfaInfo,omitempty"`
912
945
}
913
946
914
947
func (r * userQueryResponse ) makeUserRecord () (* UserRecord , error ) {
@@ -948,6 +981,28 @@ func (r *userQueryResponse) makeExportedUserRecord() (*ExportedUserRecord, error
948
981
lastRefreshTimestamp = t .Unix () * 1000
949
982
}
950
983
984
+ // Map the MFA info to a slice of enrolled factors. Currently there is only
985
+ // support for PhoneMultiFactorInfo.
986
+ var enrolledFactors []* MultiFactorInfo
987
+ for _ , factor := range r .MFAInfo {
988
+ var enrollmentTimestamp int64
989
+ if factor .EnrolledAt != "" {
990
+ t , err := time .Parse (time .RFC3339 , factor .EnrolledAt )
991
+ if err != nil {
992
+ return nil , err
993
+ }
994
+ enrollmentTimestamp = t .Unix () * 1000
995
+ }
996
+
997
+ enrolledFactors = append (enrolledFactors , & MultiFactorInfo {
998
+ UID : factor .MFAEnrollmentID ,
999
+ DisplayName : factor .DisplayName ,
1000
+ EnrollmentTimestamp : enrollmentTimestamp ,
1001
+ FactorID : Phone ,
1002
+ PhoneNumber : factor .PhoneInfo ,
1003
+ })
1004
+ }
1005
+
951
1006
return & ExportedUserRecord {
952
1007
UserRecord : & UserRecord {
953
1008
UserInfo : & UserInfo {
@@ -969,6 +1024,9 @@ func (r *userQueryResponse) makeExportedUserRecord() (*ExportedUserRecord, error
969
1024
CreationTimestamp : r .CreationTimestamp ,
970
1025
LastRefreshTimestamp : lastRefreshTimestamp ,
971
1026
},
1027
+ MultiFactor : & MultiFactorSettings {
1028
+ EnrolledFactors : enrolledFactors ,
1029
+ },
972
1030
},
973
1031
PasswordHash : hash ,
974
1032
PasswordSalt : r .PasswordSalt ,
0 commit comments