OAuth: Return SocialError on membership check failure (#98330)
use socialerror
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/mail"
|
"net/mail"
|
||||||
@@ -320,11 +319,11 @@ func (s *SocialGenericOAuth) UserInfo(ctx context.Context, client *http.Client,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !s.isTeamMember(ctx, 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) {
|
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) {
|
if !s.isGroupMember(userInfo.Groups) {
|
||||||
|
|||||||
Reference in New Issue
Block a user