remove user from all oidc teams if token is empty

This commit is contained in:
viehlieb 2023-02-01 16:35:12 +01:00
parent c7bf4e8476
commit 6418e216c7
1 changed files with 4 additions and 13 deletions

View File

@ -210,15 +210,12 @@ func HandleCallback(c echo.Context) error {
return handler.HandleHTTPError(err, c)
}
//TODO: fix this error check
// nil is no problem
//find old teams for user through oidc
oldOidcTeams, _ := models.FindAllOidcTeamIDsForUser(s, u.ID)
var oidcTeams []int64
if len(teamData) > 0 {
//find old teams for user through oidc
oldOidcTeams, _ := models.FindAllOidcTeamIDsForUser(s, u.ID)
// check if we have seen these teams before.
// find or create Teams and assign user as teammember.
var oidcTeams []int64
log.Debugf("TeamData is set %v", teamData)
teams, err := GetOrCreateTeamsByOIDCAndNames(s, teamData, u)
if err != nil {
@ -238,8 +235,8 @@ func HandleCallback(c echo.Context) error {
}
oidcTeams = append(oidcTeams, team.ID)
}
SignOutFromOrDeleteTeamsByID(s, u, notIn(oldOidcTeams, oidcTeams))
}
SignOutFromOrDeleteTeamsByID(s, u, notIn(oldOidcTeams, oidcTeams))
err = s.Commit()
if err != nil {
_ = s.Rollback()
@ -341,12 +338,6 @@ func GetOrCreateTeamsByOIDCAndNames(s *xorm.Session, teamData []TeamData, u *use
return te, err
}
// assign user to team
// remove user from team if not in group
// if multiple teams found with same name -> do nothing
// optional: assign by id
//
func getOrCreateUser(s *xorm.Session, cl *claims, issuer, subject string) (u *user.User, err error) {
// Check if the user exists for that issuer and subject