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
1 changed files with 5 additions and 4 deletions
Showing only changes of commit 6d33a513be - Show all commits

View File

@ -131,17 +131,18 @@ func GetTeamByID(s *xorm.Session, id int64) (team *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) {
func GetTeamByOidcIDAndName(s *xorm.Session, oidcID string, teamName string) (*Team, error) {
viehlieb marked this conversation as resolved Outdated

Please return a pointer to a

Please return a pointer to a

team i suppose.done, tx

team i suppose.done, tx
team := &Team{}
has, err := s.
Table("teams").
Where("oidc_id = ? AND name = ?", oidcID, teamName).
Asc("id").
konrad marked this conversation as resolved Outdated

Did you try passing the

Did you try passing the

Ups, I guess here is something missing

Ups, I guess here is something missing
Limit(1).
Get(&team)
Get(team)
viehlieb marked this conversation as resolved Outdated

Get will always return one entry, no need for Asc or Limit.

`Get` will always return one entry, no need for `Asc` or `Limit`.
if !has || err != nil {
return team, ErrOIDCTeamDoesNotExist{teamName, oidcID}
return nil, ErrOIDCTeamDoesNotExist{teamName, oidcID}
}
return team, err
return team, nil
}
func FindAllOidcTeamIDsForUser(s *xorm.Session, userID int64) (ts []int64, err error) {