remove manage admin function, nullcheck for oidc_id, undo removal of * in method TableName

This commit is contained in:
viehlieb 2023-02-13 17:24:42 +01:00
parent e0a1eae268
commit 37ccc008ee
1 changed files with 4 additions and 9 deletions

View File

@ -82,7 +82,7 @@ type TeamMember struct {
}
// TableName makes beautiful table names
func (TeamMember) TableName() string {
func (*TeamMember) TableName() string {
return "team_members"
}
@ -94,6 +94,7 @@ type TeamUser struct {
TeamID int64 `json:"-"`
}
// TeamData is the relevant data for a team and is delivered by oidc token
type TeamData struct {
TeamName string
OidcID string
@ -166,7 +167,7 @@ func FindAllOidcTeamIDsForUser(s *xorm.Session, userID int64) (ts []int64, err e
Table("team_members").
Where("user_id = ? ", userID).
Join("RIGHT", "teams", "teams.id = team_members.team_id").
Where("teams.oidc_id != ?", "").
Where("teams.oidc_id != ? AND teams.oidc_id IS NOT NULL", "").
Cols("teams.id").
Find(&ts)
if ts == nil || err != nil {
@ -325,8 +326,7 @@ func (t *Team) Create(s *xorm.Session, a web.Auth) (err error) {
return
}
var admin = true
tm := TeamMember{TeamID: t.ID, Username: doer.Username, Admin: admin}
tm := TeamMember{TeamID: t.ID, Username: doer.Username, Admin: true}
if err = tm.Create(s, doer); err != nil {
return err
}
@ -337,11 +337,6 @@ func (t *Team) Create(s *xorm.Session, a web.Auth) (err error) {
})
}
func (t *Team) ManageAdminRight(teamMember TeamMember, admin bool) {
// Insert the current user as member and admin
teamMember.Admin = admin
}
// Delete deletes a team
// @Summary Deletes a team
// @Description Delets a team. This will also remove the access for all users in that team.