feat: assign users to teams via OIDC claims #1393
|
@ -150,13 +150,13 @@ func GetTeamsByName(s *xorm.Session, name string) (teams []*Team, err error) {
|
|||
// GetTeamByOidcIDAndName gets teams where oidc_id and name match parameters
|
||||
// For oidc team creation oidcID and Name need to be set
|
||||
func GetTeamByOidcIDAndName(s *xorm.Session, oidcID string, teamName string) (team Team, err error) {
|
||||
err = s.
|
||||
has, err := s.
|
||||
Table("teams").
|
||||
viehlieb marked this conversation as resolved
Outdated
|
||||
Where("oidc_id = ? AND name = ?", oidcID, teamName).
|
||||
OrderBy("name ASC").
|
||||
Asc("id").
|
||||
Limit(1).
|
||||
viehlieb marked this conversation as resolved
Outdated
konrad
commented
What happens if there's more than one team with that combination (unlikely, but not handled) What happens if there's more than one team with that combination (unlikely, but not handled)
viehlieb
commented
I tend to just changing functionality to take the first team with that specific setting. I tend to just changing functionality to take the first team with that specific setting.
konrad
commented
That sounds like it could work. Easiest way would be to add a That sounds like it could work. Easiest way would be to add a `OrderBy` clause here.
|
||||
Find(&team)
|
||||
if err != nil {
|
||||
Get(&team)
|
||||
if !has || err != nil {
|
||||
return team, ErrOIDCTeamDoesNotExist{teamName, oidcID}
|
||||
}
|
||||
viehlieb marked this conversation as resolved
Outdated
konrad
commented
This error message should contain the name as well. This error message should contain the name as well.
|
||||
return team, err
|
||||
|
|
Loading…
Reference in New Issue
Block a user
Please handle the error.