Smol optimisation for existing auth system
This commit is contained in:
parent
57214ecde0
commit
66d6299295
1 changed files with 4 additions and 6 deletions
|
@ -2,8 +2,9 @@ package auth
|
|||
|
||||
import (
|
||||
"git.mstar.dev/mstar/goutils/sliceutils"
|
||||
"git.mstar.dev/mstar/linstrom/storage"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"git.mstar.dev/mstar/linstrom/storage"
|
||||
)
|
||||
|
||||
// Can actorId read the account with targetId?
|
||||
|
@ -33,17 +34,14 @@ func (a *Authentication) CanReadAccount(actorId *string, targetId string) bool {
|
|||
return false
|
||||
}
|
||||
combined := storage.CollapseRolesIntoOne(roles...)
|
||||
if sliceutils.Contains(combined.BlockedUsers, *actorId) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return !sliceutils.Contains(combined.BlockedUsers, *actorId)
|
||||
}
|
||||
|
||||
// Can actorId edit the account with targetId?
|
||||
// If actorId is nil, it is assumed to be an anonymous user trying to edit the target account
|
||||
// if targetId is nil, it is assumed that the actor is editing themselves
|
||||
func (a *Authentication) CanEditAccount(actorId *string, targetId *string) bool {
|
||||
// FIXME: This entire function feels wrong, idk
|
||||
// WARN: This entire function feels wrong, idk
|
||||
// Only the owner of an account should be able to edit said account's data
|
||||
// But how do moderation actions play with this? Do they count as edit or as something separate?
|
||||
if actorId == nil {
|
||||
|
|
Loading…
Reference in a new issue