@@ -57,6 +57,37 @@ type UserInfo struct {
5757 UID string `json:"rawId,omitempty"`
5858}
5959
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+
6091// UserMetadata contains additional metadata associated with a user account.
6192// Timestamps are in milliseconds since epoch.
6293type UserMetadata struct {
@@ -77,6 +108,7 @@ type UserRecord struct {
77108 TokensValidAfterMillis int64 // milliseconds since epoch.
78109 UserMetadata * UserMetadata
79110 TenantID string
111+ MultiFactor * MultiFactorSettings
80112}
81113
82114// UserToCreate is the parameter struct for the CreateUser function.
@@ -892,23 +924,24 @@ func (c *baseClient) GetUsers(
892924}
893925
894926type 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"`
912945}
913946
914947func (r * userQueryResponse ) makeUserRecord () (* UserRecord , error ) {
@@ -948,6 +981,28 @@ func (r *userQueryResponse) makeExportedUserRecord() (*ExportedUserRecord, error
948981 lastRefreshTimestamp = t .Unix () * 1000
949982 }
950983
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+
9511006 return & ExportedUserRecord {
9521007 UserRecord : & UserRecord {
9531008 UserInfo : & UserInfo {
@@ -969,6 +1024,9 @@ func (r *userQueryResponse) makeExportedUserRecord() (*ExportedUserRecord, error
9691024 CreationTimestamp : r .CreationTimestamp ,
9701025 LastRefreshTimestamp : lastRefreshTimestamp ,
9711026 },
1027+ MultiFactor : & MultiFactorSettings {
1028+ EnrolledFactors : enrolledFactors ,
1029+ },
9721030 },
9731031 PasswordHash : hash ,
9741032 PasswordSalt : r .PasswordSalt ,
0 commit comments