fix: review comments batch 3

This commit is contained in:
Stavros
2026-05-05 18:56:35 +03:00
parent e04980468f
commit 04b2290d73
+13 -3
View File
@@ -12,8 +12,9 @@ import (
) )
type GithubEmailResponse []struct { type GithubEmailResponse []struct {
Email string `json:"email"` Email string `json:"email"`
Primary bool `json:"primary"` Primary bool `json:"primary"`
Verified bool `json:"verified"`
} }
type GithubUserInfoResponse struct { type GithubUserInfoResponse struct {
@@ -56,7 +57,16 @@ func githubExtractor(client *http.Client, url string) (*model.Claims, error) {
// Use first available email if no primary email was found // Use first available email if no primary email was found
if user.Email == "" { if user.Email == "" {
user.Email = (*userEmails)[0].Email for _, email := range *userEmails {
if email.Verified {
user.Email = email.Email
break
}
}
}
if user.Email == "" {
return nil, errors.New("no verified email found")
} }
user.PreferredUsername = userInfo.Login user.PreferredUsername = userInfo.Login