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 (
|
import (
|
||||||
"git.mstar.dev/mstar/goutils/sliceutils"
|
"git.mstar.dev/mstar/goutils/sliceutils"
|
||||||
"git.mstar.dev/mstar/linstrom/storage"
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
|
"git.mstar.dev/mstar/linstrom/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Can actorId read the account with targetId?
|
// Can actorId read the account with targetId?
|
||||||
|
@ -33,17 +34,14 @@ func (a *Authentication) CanReadAccount(actorId *string, targetId string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
combined := storage.CollapseRolesIntoOne(roles...)
|
combined := storage.CollapseRolesIntoOne(roles...)
|
||||||
if sliceutils.Contains(combined.BlockedUsers, *actorId) {
|
return !sliceutils.Contains(combined.BlockedUsers, *actorId)
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can actorId edit the account with targetId?
|
// 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 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
|
// if targetId is nil, it is assumed that the actor is editing themselves
|
||||||
func (a *Authentication) CanEditAccount(actorId *string, targetId *string) bool {
|
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
|
// 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?
|
// But how do moderation actions play with this? Do they count as edit or as something separate?
|
||||||
if actorId == nil {
|
if actorId == nil {
|
||||||
|
|
Loading…
Reference in a new issue