From 500b761fe6aa06d7eae7bf1d306c4df96b174d93 Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 12 Apr 2024 18:02:39 +0200 Subject: [PATCH] fix(projects): do not return parent project id when authenticating as link share Related to https://community.vikunja.io/t/vikunja-freezes/2246 Related to https://github.com/go-vikunja/vikunja/issues/233 --- pkg/models/project.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/models/project.go b/pkg/models/project.go index 05df0e681..5abdd82f2 100644 --- a/pkg/models/project.go +++ b/pkg/models/project.go @@ -146,6 +146,9 @@ func (p *Project) ReadAll(s *xorm.Session, a web.Auth, search string, page int, } projects := []*Project{project} err = addProjectDetails(s, projects, a) + if err == nil && len(projects) > 0 { + projects[0].ParentProjectID = 0 + } return projects, 0, 0, err } @@ -226,6 +229,11 @@ func (p *Project) ReadOne(s *xorm.Session, a web.Auth) (err error) { p.OwnerID = sf.OwnerID } + _, isShareAuth := a.(*LinkSharing) + if isShareAuth { + p.ParentProjectID = 0 + } + // Get project owner p.Owner, err = user.GetUserByID(s, p.OwnerID) if err != nil {