feat: assign users to teams via OIDC claims #1393

Merged
konrad merged 93 commits from viehlieb/api:950_reworked_assign_teams_via_oidc into main 2024-03-02 08:47:12 +00:00
Showing only changes of commit 3f4b3853a3 - Show all commits

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").
viehlieb marked this conversation as resolved Outdated

Please handle the error.

Please handle the error.
Where("oidc_id = ? AND name = ?", oidcID, teamName).
OrderBy("name ASC").
Asc("id").
Limit(1).
viehlieb marked this conversation as resolved Outdated

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)

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.

That sounds like it could work. Easiest way would be to add a OrderBy clause here.

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

This error message should contain the name as well.

This error message should contain the name as well.
return team, err