Skip to content

Commit 7507822

Browse files
ymiedviedievhf
andauthored
feat: fetch email from snapchat oauth provider if available for consistency (#2110)
## What kind of change does this PR introduce? This is an update to the existing Snapchat OAuth provider, which was previously not capable of Email field. Now if Email field is present in the response, it is handled accordingly ## What is the current behavior? Current behaviour is that Email field is never handled in the Snapchat provider ## What is the new behavior? New behaviour is that if Email is present in the response - it is set to claims accordingly Co-authored-by: Stojan Dimitrovski <[email protected]>
1 parent 9a61dae commit 7507822

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

internal/api/external_snapchat_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
)
1111

1212
const (
13-
snapchatUser = `{"data":{"me":{"externalId":"snapchatTestId","displayName":"Snapchat Test","bitmoji":{"avatar":"http://example.com/bitmoji"}}}}`
13+
snapchatUser = `{"data":{"me":{"email":"[email protected]","externalId":"snapchatTestId","displayName":"Snapchat Test","bitmoji":{"avatar":"http://example.com/bitmoji"}}}}`
1414
)
1515

1616
func (ts *ExternalTestSuite) TestSignupExternalSnapchat() {

internal/api/provider/snapchat.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type snapchatUser struct {
3131
Bitmoji struct {
3232
Avatar string `json:"avatar"`
3333
} `json:"bitmoji"`
34+
Email string `json:"email"`
3435
} `json:"me"`
3536
} `json:"data"`
3637
}
@@ -94,7 +95,13 @@ func (p snapchatProvider) GetUserData(ctx context.Context, tok *oauth2.Token) (*
9495

9596
data := &UserProvidedData{}
9697

97-
// Snapchat doesn't provide email address!
98+
if u.Data.Me.Email != "" {
99+
data.Emails = []Email{{
100+
Email: u.Data.Me.Email,
101+
Verified: true,
102+
Primary: true,
103+
}}
104+
}
98105

99106
data.Metadata = &Claims{
100107
Issuer: IssuerSnapchat,

0 commit comments

Comments
 (0)