feat(auth): update team name in Vikunja when it was changed in the openid provider
continuous-integration/drone/push Build is failing Details

This commit is contained in:
kolaente 2024-03-02 15:27:15 +01:00
parent fc4303a778
commit a4a0ea973a
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 13 additions and 1 deletions

View File

@ -329,9 +329,13 @@ func getTeamDataFromToken(groups []map[string]interface{}, provider *Provider) (
return teamData, errs
}
func getOIDCTeamName(name string) string {
return name + " (OIDC)"
}
func CreateOIDCTeam(s *xorm.Session, teamData *models.OIDCTeam, u *user.User) (team *models.Team, err error) {
team = &models.Team{
Name: teamData.Name + "(OIDC)",
Name: getOIDCTeamName(teamData.Name),
Description: teamData.Description,
OidcID: teamData.OidcID,
}
@ -358,6 +362,14 @@ func GetOrCreateTeamsByOIDCAndNames(s *xorm.Session, teamData []*models.OIDCTeam
continue
}
if team.Name != getOIDCTeamName(oidcTeam.Name) {
team.Name = getOIDCTeamName(oidcTeam.Name)
err = team.Update(s, u)
if err != nil {
return nil, err
}
}
log.Debugf("Team with oidc_id %v and name %v already exists.", team.OidcID, team.Name)
te = append(te, team)
}