feat: assign users to teams via OIDC claims #1393
|
@ -82,7 +82,7 @@ type TeamMember struct {
|
|||
}
|
||||
|
||||
// TableName makes beautiful table names
|
||||
func (TeamMember) TableName() string {
|
||||
func (*TeamMember) TableName() string {
|
||||
viehlieb marked this conversation as resolved
Outdated
|
||||
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
|
||||
viehlieb marked this conversation as resolved
Outdated
konrad
commented
What is this used for? Please add a comment. What is this used for? Please add a comment.
konrad
commented
What's the difference to the What's the difference to the `Team` struct?
viehlieb
commented
Intermediate struct which only holds TeamName and OidcId Description. Intermediate struct which only holds TeamName and OidcId Description.
It does not exist as a Team yet or better: it is the data accessible via oidc, which the Team struct is compared against.
konrad
commented
Okay, but isn't it missing the json tags then? I'm not sure if I understood you correctly herre. If it's only used for oidc data the name should reflect that. Okay, but isn't it missing the json tags then? I'm not sure if I understood you correctly herre.
If it's only used for oidc data the name should reflect that. `TeamData` is too generic.
viehlieb
commented
No, the teamData has to be pulled out of token via
Called it OIDCTeamData now. No, the teamData has to be pulled out of token via
`getTeamDataFromToken`
Called it OIDCTeamData now.
|
||||
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").
|
||||
viehlieb marked this conversation as resolved
Outdated
konrad
commented
Can Can `teams.oidc_id` be null? Then you should check that as well.
|
||||
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}
|
||||
viehlieb marked this conversation as resolved
Outdated
konrad
commented
Why the extra variable? Why the extra variable?
viehlieb
commented
manageAdmin func and this var are deleted from code, since not needed manageAdmin func and this var are deleted from code, since not needed
viehlieb
commented
manageAdmin func and this var are deleted from code, since not needed manageAdmin func and this var are deleted from code, since not needed
|
||||
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
|
||||
viehlieb marked this conversation as resolved
Outdated
konrad
commented
That's not what the function seems to be doing. Please change the name or comment. That's not what the function seems to be doing. Please change the name or comment.
|
||||
// @Description Delets a team. This will also remove the access for all users in that team.
|
||||
|
|
Why did you change this?
oha.
this was unintended.