Skip to content

Commit

Permalink
[v11.2.x] OAuth: Return SocialError on membership check failure (#98859)
Browse files Browse the repository at this point in the history
OAuth: Return SocialError on membership check failure (#98330)

use socialerror

(cherry picked from commit ddca09f)

Co-authored-by: Daniel-Davies <33356828+Daniel-Davies@users.noreply.github.com>
  • Loading branch information
grafana-delivery-bot[bot] and Daniel-Davies authored Jan 13, 2025
1 parent de68050 commit bc7b67f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pkg/login/social/connectors/generic_oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/mail"
Expand Down Expand Up @@ -320,11 +319,11 @@ func (s *SocialGenericOAuth) UserInfo(ctx context.Context, client *http.Client,
}

if !s.isTeamMember(ctx, client) {
return nil, errors.New("user not a member of one of the required teams")
return nil, &SocialError{"User not a member of one of the required teams"}
}

if !s.isOrganizationMember(ctx, client) {
return nil, errors.New("user not a member of one of the required organizations")
return nil, &SocialError{"User not a member of one of the required organizations"}
}

if !s.isGroupMember(userInfo.Groups) {
Expand Down

0 comments on commit bc7b67f

Please sign in to comment.