fix(project): transfer ownership after deleting a user

This fixes a bug where the ownership of a project was not transferred when the user was deleted, leading to errors when viewing the project, as the owner user could not be found.

Resolves https://kolaente.dev/vikunja/vikunja/issues/2827
This commit is contained in:
kolaente 2025-01-20 12:25:38 +01:00
parent 0e37049343
commit 4858f7c82f
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
1 changed files with 11 additions and 0 deletions

View File

@ -192,6 +192,17 @@ func ensureProjectAdminUser(s *xorm.Session, l *Project) (hadUsers bool, err err
_, err = s.Where("id = ?", firstUser.ID).
Cols("right").
Update(firstUser)
if err != nil {
return true, err
}
_, err = s.Where("id = ?", l.ID).
Cols("owner_id").
Update(&Project{OwnerID: firstUser.UserID})
if err != nil {
return true, err
}
return true, err
}