mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-10-22 04:32:02 +02:00
Some code improvements
* Remove shadowing of predeclared identifier: new. * strings.ReplaceAll instead of strings.Replace with -1. * Change strings.ToLower comparison to strings.EqualFold. * Rewrite if-else-if-else chain as a switch.
This commit is contained in:
+4
-3
@@ -195,9 +195,10 @@ func userInGroup(service *admin.Service, groups []string, email string) bool {
|
||||
r, err := req.Do()
|
||||
if err != nil {
|
||||
err, ok := err.(*googleapi.Error)
|
||||
if ok && err.Code == 404 {
|
||||
switch {
|
||||
case ok && err.Code == 404:
|
||||
logger.Printf("error checking membership in group %s: group does not exist", group)
|
||||
} else if ok && err.Code == 400 {
|
||||
case ok && err.Code == 400:
|
||||
// It is possible for Members.HasMember to return false even if the email is a group member.
|
||||
// One case that can cause this is if the user email is from a different domain than the group,
|
||||
// e.g. "member@otherdomain.com" in the group "group@mydomain.com" will result in a 400 error
|
||||
@@ -215,7 +216,7 @@ func userInGroup(service *admin.Service, groups []string, email string) bool {
|
||||
if r.Status == "ACTIVE" {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
default:
|
||||
logger.Printf("error checking group membership: %v", err)
|
||||
}
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user