fix(lists): return correct max right for lists where the user has created the namespace
This commit is contained in:
parent
f6b897e8e7
commit
9fc08a0790
@ -202,7 +202,7 @@ func (l *List) isOwner(u *user.User) bool {
|
|||||||
func (l *List) checkRight(s *xorm.Session, a web.Auth, rights ...Right) (bool, int, error) {
|
func (l *List) checkRight(s *xorm.Session, a web.Auth, rights ...Right) (bool, int, error) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The following loop creates an sql condition like this one:
|
The following loop creates a sql condition like this one:
|
||||||
|
|
||||||
(ul.user_id = 1 AND ul.right = 1) OR (un.user_id = 1 AND un.right = 1) OR
|
(ul.user_id = 1 AND ul.right = 1) OR (un.user_id = 1 AND un.right = 1) OR
|
||||||
(tm.user_id = 1 AND tn.right = 1) OR (tm2.user_id = 1 AND tl.right = 1) OR
|
(tm.user_id = 1 AND tn.right = 1) OR (tm2.user_id = 1 AND tl.right = 1) OR
|
||||||
@ -242,16 +242,19 @@ func (l *List) checkRight(s *xorm.Session, a web.Auth, rights ...Right) (bool, i
|
|||||||
conds = append(conds, builder.Eq{"n.owner_id": a.GetID()})
|
conds = append(conds, builder.Eq{"n.owner_id": a.GetID()})
|
||||||
|
|
||||||
type allListRights struct {
|
type allListRights struct {
|
||||||
UserNamespace NamespaceUser `xorm:"extends"`
|
UserNamespace *NamespaceUser `xorm:"extends"`
|
||||||
UserList ListUser `xorm:"extends"`
|
UserList *ListUser `xorm:"extends"`
|
||||||
|
|
||||||
TeamNamespace TeamNamespace `xorm:"extends"`
|
TeamNamespace *TeamNamespace `xorm:"extends"`
|
||||||
TeamList TeamList `xorm:"extends"`
|
TeamList *TeamList `xorm:"extends"`
|
||||||
|
|
||||||
|
NamespaceOwnerID int64 `xorm:"namespaces_owner_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
r := &allListRights{}
|
r := &allListRights{}
|
||||||
var maxRight = 0
|
var maxRight = 0
|
||||||
exists, err := s.
|
exists, err := s.
|
||||||
|
Select("l.*, un.right, ul.right, tn.right, tl.right, n.owner_id as namespaces_owner_id").
|
||||||
Table("lists").
|
Table("lists").
|
||||||
Alias("l").
|
Alias("l").
|
||||||
// User stuff
|
// User stuff
|
||||||
@ -285,6 +288,9 @@ func (l *List) checkRight(s *xorm.Session, a web.Auth, rights ...Right) (bool, i
|
|||||||
if int(r.TeamList.Right) > maxRight {
|
if int(r.TeamList.Right) > maxRight {
|
||||||
maxRight = int(r.TeamList.Right)
|
maxRight = int(r.TeamList.Right)
|
||||||
}
|
}
|
||||||
|
if r.NamespaceOwnerID == a.GetID() {
|
||||||
|
maxRight = int(RightAdmin)
|
||||||
|
}
|
||||||
|
|
||||||
return exists, maxRight, err
|
return exists, maxRight, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user