Skip to content

Commit 37c7936

Browse files
Merge dev into master
2 parents 74c9bd5 + 5e861fd commit 37c7936

File tree

5 files changed

+26
-25
lines changed

5 files changed

+26
-25
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
# 3. with the label 'release:publish', and
7272
# 4. the title prefix '[chore] Release '.
7373
if: github.event.pull_request.merged &&
74-
github.ref == 'dev' &&
74+
github.ref == 'refs/heads/dev' &&
7575
contains(github.event.pull_request.labels.*.name, 'release:publish') &&
7676
startsWith(github.event.pull_request.title, '[chore] Release ')
7777

auth/user_mgt.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ type multiFactorInfoResponse struct {
6868
EnrolledAt string `json:"enrolledAt,omitempty"`
6969
}
7070

71+
type multiFactorEnrollments struct {
72+
Enrollments []*multiFactorInfoResponse `json:"enrollments"`
73+
}
74+
7175
// MultiFactorInfo describes a user enrolled second phone factor.
7276
// TODO : convert PhoneNumber to PhoneMultiFactorInfo struct
7377
type MultiFactorInfo struct {
@@ -166,18 +170,19 @@ func (u *UserToCreate) set(key string, value interface{}) *UserToCreate {
166170

167171
// Converts a client format second factor object to server format.
168172
func convertMultiFactorInfoToServerFormat(mfaInfo MultiFactorInfo) (multiFactorInfoResponse, error) {
169-
var authFactorInfo multiFactorInfoResponse
173+
authFactorInfo := multiFactorInfoResponse{DisplayName: mfaInfo.DisplayName}
170174
if mfaInfo.EnrollmentTimestamp != 0 {
171175
authFactorInfo.EnrolledAt = time.Unix(mfaInfo.EnrollmentTimestamp, 0).Format("2006-01-02T15:04:05Z07:00Z")
172176
}
177+
if mfaInfo.UID != "" {
178+
authFactorInfo.MFAEnrollmentID = mfaInfo.UID
179+
}
173180
if mfaInfo.FactorID == phoneMultiFactorID {
174181
authFactorInfo.PhoneInfo = mfaInfo.PhoneNumber
175-
authFactorInfo.DisplayName = mfaInfo.DisplayName
176-
authFactorInfo.MFAEnrollmentID = mfaInfo.UID
177182
return authFactorInfo, nil
178183
}
179184
out, _ := json.Marshal(mfaInfo)
180-
return multiFactorInfoResponse{}, fmt.Errorf("Unsupported second factor %s provided", string(out))
185+
return multiFactorInfoResponse{}, fmt.Errorf("unsupported second factor %s provided", string(out))
181186
}
182187

183188
func (u *UserToCreate) validatedRequest() (map[string]interface{}, error) {
@@ -333,7 +338,9 @@ func (u *UserToUpdate) validatedRequest() (map[string]interface{}, error) {
333338
if err != nil {
334339
return nil, err
335340
}
336-
req["mfaInfo"] = mfaInfo
341+
342+
// https://cloud.google.com/identity-platform/docs/reference/rest/v1/accounts/update
343+
req["mfa"] = multiFactorEnrollments{mfaInfo}
337344
} else {
338345
req[k] = v
339346
}
@@ -665,9 +672,6 @@ func validateAndFormatMfaSettings(mfaSettings MultiFactorSettings, methodType st
665672
return nil, fmt.Errorf("\"uid\" is not supported when adding second factors via \"createUser()\"")
666673
}
667674
case updateUserMethod:
668-
if multiFactorInfo.UID == "" {
669-
return nil, fmt.Errorf("the second factor \"uid\" must be a valid non-empty string when adding second factors via \"updateUser()\"")
670-
}
671675
default:
672676
return nil, fmt.Errorf("unsupported methodType: %s", methodType)
673677
}

auth/user_mgt_test.go

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -894,17 +894,6 @@ func TestInvalidUpdateUser(t *testing.T) {
894894
},
895895
}),
896896
`the second factor "phoneNumber" for "invalid" must be a non-empty E.164 standard compliant identifier string`,
897-
}, {
898-
(&UserToUpdate{}).MFASettings(MultiFactorSettings{
899-
EnrolledFactors: []*MultiFactorInfo{
900-
{
901-
PhoneNumber: "+11234567890",
902-
FactorID: "phone",
903-
DisplayName: "Spouse's phone number",
904-
},
905-
},
906-
}),
907-
`the second factor "uid" must be a valid non-empty string when adding second factors via "updateUser()"`,
908897
}, {
909898
(&UserToUpdate{}).ProviderToLink(&UserProvider{UID: "google_uid"}),
910899
"user provider must specify a provider ID",
@@ -1059,10 +1048,14 @@ var updateUserCases = []struct {
10591048
PhoneNumber: "+11234567890",
10601049
DisplayName: "Spouse's phone number",
10611050
FactorID: "phone",
1051+
}, {
1052+
PhoneNumber: "+11234567890",
1053+
DisplayName: "Spouse's phone number",
1054+
FactorID: "phone",
10621055
},
10631056
},
10641057
}),
1065-
map[string]interface{}{"mfaInfo": []*multiFactorInfoResponse{
1058+
map[string]interface{}{"mfa": multiFactorEnrollments{Enrollments: []*multiFactorInfoResponse{
10661059
{
10671060
MFAEnrollmentID: "enrolledSecondFactor1",
10681061
PhoneInfo: "+11234567890",
@@ -1074,12 +1067,16 @@ var updateUserCases = []struct {
10741067
DisplayName: "Spouse's phone number",
10751068
PhoneInfo: "+11234567890",
10761069
},
1077-
},
1070+
{
1071+
DisplayName: "Spouse's phone number",
1072+
PhoneInfo: "+11234567890",
1073+
},
1074+
}},
10781075
},
10791076
},
10801077
{
10811078
(&UserToUpdate{}).MFASettings(MultiFactorSettings{}),
1082-
map[string]interface{}{"mfaInfo": nil},
1079+
map[string]interface{}{"mfa": multiFactorEnrollments{Enrollments: nil}},
10831080
},
10841081
{
10851082
(&UserToUpdate{}).ProviderToLink(&UserProvider{

firebase.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
var defaultAuthOverrides = make(map[string]interface{})
4040

4141
// Version of the Firebase Go Admin SDK.
42-
const Version = "4.12.0"
42+
const Version = "4.12.1"
4343

4444
// firebaseEnvName is the name of the environment variable with the Config.
4545
const firebaseEnvName = "FIREBASE_CONFIG"

messaging/messaging_batch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (c *fcmClient) SendEachDryRun(ctx context.Context, messages []*Message) (*B
116116
return c.sendEachInBatch(ctx, messages, true)
117117
}
118118

119-
// SendMulticast sends the given multicast message to all the FCM registration tokens specified.
119+
// SendEachForMulticast sends the given multicast message to all the FCM registration tokens specified.
120120
//
121121
// The tokens array in MulticastMessage may contain up to 500 tokens. SendMulticast uses the
122122
// SendEach() function to send the given message to all the target recipients. The

0 commit comments

Comments
 (0)