feat: preferably award admin access to project users with write access on user deletion (#2772)

Reviewed-on: https://kolaente.dev/vikunja/vikunja/pulls/2772
Co-authored-by: Sterad <hgasuser@gmail.com>
Co-committed-by: Sterad <hgasuser@gmail.com>
This commit is contained in:
Sterad 2024-10-24 20:42:38 +00:00 committed by konrad
parent 4b464b3216
commit 1f76a8bb64
1 changed files with 20 additions and 0 deletions

View File

@ -177,6 +177,16 @@ func ensureProjectAdminUser(s *xorm.Session, l *Project) (hadUsers bool, err err
}
}
for _, lu := range projectUsers {
if lu.Right == RightWrite {
lu.Right = RightAdmin
_, err = s.Where("id = ?", lu.ID).
Cols("right").
Update(lu)
return true, err
}
}
firstUser := projectUsers[0]
firstUser.Right = RightAdmin
_, err = s.Where("id = ?", firstUser.ID).
@ -203,6 +213,16 @@ func ensureProjectAdminTeam(s *xorm.Session, l *Project) (hadTeams bool, err err
}
}
for _, lu := range projectTeams {
if lu.Right == RightWrite {
lu.Right = RightAdmin
_, err = s.Where("id = ?", lu.ID).
Cols("right").
Update(lu)
return true, err
}
}
firstTeam := projectTeams[0]
firstTeam.Right = RightAdmin
_, err = s.Where("id = ?", firstTeam.ID).