fix limit GetTeamByOidcIDAndName to get a single team

This commit is contained in:
viehlieb 2023-05-08 15:41:24 +02:00
parent a5b6937809
commit 9007ec4a0a
1 changed files with 4 additions and 4 deletions

View File

@ -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").
Where("oidc_id = ? AND name = ?", oidcID, teamName).
OrderBy("name ASC").
Asc("id").
Limit(1).
Find(&team)
if err != nil {
Get(&team)
if !has || err != nil {
return team, ErrOIDCTeamDoesNotExist{teamName, oidcID}
}
return team, err