Merge pull request #357 from wrapp/skip-group-lookup-404
Skip 404 errors when looking up Google groups
This commit is contained in:
commit
cd0d13e3fb
@ -17,6 +17,7 @@ import (
|
|||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
"golang.org/x/oauth2/google"
|
"golang.org/x/oauth2/google"
|
||||||
"google.golang.org/api/admin/directory/v1"
|
"google.golang.org/api/admin/directory/v1"
|
||||||
|
"google.golang.org/api/googleapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
type GoogleProvider struct {
|
type GoogleProvider struct {
|
||||||
@ -197,9 +198,13 @@ func userInGroup(service *admin.Service, groups []string, email string) bool {
|
|||||||
for _, group := range groups {
|
for _, group := range groups {
|
||||||
members, err := fetchGroupMembers(service, group)
|
members, err := fetchGroupMembers(service, group)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if err, ok := err.(*googleapi.Error); ok && err.Code == 404 {
|
||||||
|
log.Printf("error fetching members for group %s: group does not exist", group)
|
||||||
|
} else {
|
||||||
log.Printf("error fetching group members: %v", err)
|
log.Printf("error fetching group members: %v", err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, member := range members {
|
for _, member := range members {
|
||||||
switch member.Type {
|
switch member.Type {
|
||||||
|
Loading…
Reference in New Issue
Block a user