1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-01-09 10:07:17 +02:00

Merge branch 'master' into yuxiang-gao-gitee-oauth

This commit is contained in:
Gani Georgiev 2022-12-31 15:00:19 +02:00
commit a7aa3da67e

View File

@ -64,8 +64,8 @@ func (p *Github) FetchAuthUser(token *oauth2.Token) (*AuthUser, error) {
AccessToken: token.AccessToken,
}
// in case user set "Keep my email address private",
// email should be retrieved via extra API request
// in case user has set "Keep my email address private", send an
// **optional** API request to retrieve the verified primary email
if user.Email == "" {
client := p.Client(token)
@ -75,6 +75,12 @@ func (p *Github) FetchAuthUser(token *oauth2.Token) (*AuthUser, error) {
}
defer response.Body.Close()
// ignore not found errors caused by unsufficient scope permissions
// (the email field is optional, return the auth user without it)
if response.StatusCode == 404 {
return user, nil
}
content, err := io.ReadAll(response.Body)
if err != nil {
return user, err