fmt
This commit is contained in:
parent
c43db9929b
commit
6d971c5fe1
1 changed files with 7 additions and 7 deletions
|
@ -8,7 +8,7 @@ func (n *Namespace) IsAdmin(user *User) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check user rights
|
// Check user rights
|
||||||
if n.checkUserRights(user, UserRightAdmin){
|
if n.checkUserRights(user, UserRightAdmin) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ func (n *Namespace) CanWrite(user *User) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check user rights
|
// Check user rights
|
||||||
if n.checkUserRights(user, UserRightWrite){
|
if n.checkUserRights(user, UserRightWrite) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ func (n *Namespace) CanRead(user *User) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check user rights
|
// Check user rights
|
||||||
if n.checkUserRights(user, UserRightRead){
|
if n.checkUserRights(user, UserRightRead) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,8 +71,8 @@ func (n *Namespace) checkTeamRights(user *User, r TeamRight) bool {
|
||||||
Table("namespaces").
|
Table("namespaces").
|
||||||
Join("LEFT", "team_namespaces", "namespaces.id = team_namespaces.namespace_id").
|
Join("LEFT", "team_namespaces", "namespaces.id = team_namespaces.namespace_id").
|
||||||
Join("LEFT", "team_members", "team_members.team_id = team_namespaces.team_id").
|
Join("LEFT", "team_members", "team_members.team_id = team_namespaces.team_id").
|
||||||
Where("namespaces.id = ? " +
|
Where("namespaces.id = ? "+
|
||||||
"AND ((team_members.user_id = ? AND team_namespaces.right = ?) " +
|
"AND ((team_members.user_id = ? AND team_namespaces.right = ?) "+
|
||||||
"OR namespaces.owner_id = ? ", n.ID, user.ID, r, user.ID).
|
"OR namespaces.owner_id = ? ", n.ID, user.ID, r, user.ID).
|
||||||
Get(&Namespace{})
|
Get(&Namespace{})
|
||||||
|
|
||||||
|
@ -87,8 +87,8 @@ func (n *Namespace) checkUserRights(user *User, r UserRight) bool {
|
||||||
exists, err := x.Select("namespaces.*").
|
exists, err := x.Select("namespaces.*").
|
||||||
Table("namespaces").
|
Table("namespaces").
|
||||||
Join("LEFT", "users_namespace", "users_namespace.namespace_id = namespaces.id").
|
Join("LEFT", "users_namespace", "users_namespace.namespace_id = namespaces.id").
|
||||||
Where("namespaces.id = ? " +
|
Where("namespaces.id = ? "+
|
||||||
"OR namespaces.owner_id = ? " +
|
"OR namespaces.owner_id = ? "+
|
||||||
"OR (users_namespace.user_id = ? AND users_namespace.right = ?))", n.ID, user.ID, user.ID, r).
|
"OR (users_namespace.user_id = ? AND users_namespace.right = ?))", n.ID, user.ID, user.ID, r).
|
||||||
Get(&Namespace{})
|
Get(&Namespace{})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue