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