Rights performance improvements for lists and namespaces #54

Merged
konrad merged 14 commits from improvement/rights-performance into master 2019-01-21 22:08:05 +00:00
1 changed files with 4 additions and 4 deletions
Showing only changes of commit ee3d8b4aec - Show all commits

View File

@ -28,7 +28,7 @@ func (l *List) CanWrite(a web.Auth) bool {
// Check all the things
// Check if the user is either owner or can write to the list
return l.isOwner(user) || l.checkListRight(user, ListRightWrite, ListRightAdmin)
return l.isOwner(user) || l.checkRight(user, ListRightWrite, ListRightAdmin)
}
// CanRead checks if a user has read access to a list
@ -37,7 +37,7 @@ func (l *List) CanRead(a web.Auth) bool {
// Check all the things
// Check if the user is either owner or can read
return l.isOwner(user) || l.checkListRight(user, ListRightRead, ListRightWrite, ListRightAdmin)
return l.isOwner(user) || l.checkRight(user, ListRightRead, ListRightWrite, ListRightAdmin)
}
// CanDelete checks if the user can delete a list
@ -65,7 +65,7 @@ func (l *List) IsAdmin(a web.Auth) bool {
// Check all the things
// Check if the user is either owner or can write to the list
// Owners are always admins
return l.isOwner(user) || l.checkListRight(user, ListRightAdmin)
return l.isOwner(user) || l.checkRight(user, ListRightAdmin)
}
// Little helper function to check if a user is list owner
@ -77,7 +77,7 @@ func (l *List) isOwner(u *User) bool {
}
// Checks n different rights for any given user
func (l *List) checkListRight(user *User, rights ...ListRight) bool {
func (l *List) checkRight(user *User, rights ...ListRight) bool {
/*
The following loop creates an sql condition like this one: