@@ -57,6 +57,28 @@ 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+ // 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+
6082// UserMetadata contains additional metadata associated with a user account.
6183// Timestamps are in milliseconds since epoch.
6284type UserMetadata struct {
@@ -77,6 +99,7 @@ type UserRecord struct {
7799 TokensValidAfterMillis int64 // milliseconds since epoch.
78100 UserMetadata * UserMetadata
79101 TenantID string
102+ MultiFactor * MultiFactorSettings
80103}
81104
82105// UserToCreate is the parameter struct for the CreateUser function.
@@ -892,23 +915,24 @@ func (c *baseClient) GetUsers(
892915}
893916
894917type 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"`
912936}
913937
914938func (r * userQueryResponse ) makeUserRecord () (* UserRecord , error ) {
@@ -948,6 +972,32 @@ func (r *userQueryResponse) makeExportedUserRecord() (*ExportedUserRecord, error
948972 lastRefreshTimestamp = t .Unix () * 1000
949973 }
950974
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+
9511001 return & ExportedUserRecord {
9521002 UserRecord : & UserRecord {
9531003 UserInfo : & UserInfo {
@@ -969,6 +1019,9 @@ func (r *userQueryResponse) makeExportedUserRecord() (*ExportedUserRecord, error
9691019 CreationTimestamp : r .CreationTimestamp ,
9701020 LastRefreshTimestamp : lastRefreshTimestamp ,
9711021 },
1022+ MultiFactor : & MultiFactorSettings {
1023+ EnrolledFactors : enrolledFactors ,
1024+ },
9721025 },
9731026 PasswordHash : hash ,
9741027 PasswordSalt : r .PasswordSalt ,
0 commit comments