mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-23 13:56:14 -06:00
tweak scope matcher
This commit is contained in:
parent
7000196d84
commit
c8edd5f142
1 changed files with 11 additions and 1 deletions
|
|
@ -93,6 +93,14 @@ const (
|
|||
// scope permits the wanted scope.
|
||||
func (has Scope) Permits(wanted Scope) bool {
|
||||
switch {
|
||||
|
||||
// Exact match.
|
||||
case has == wanted:
|
||||
return true
|
||||
|
||||
// Check if we have a parent scope
|
||||
// of what's wanted, eg., we have
|
||||
// "admin", we want "admin:read".
|
||||
case has == ScopeRead:
|
||||
return strings.HasPrefix(string(wanted), string(ScopeRead))
|
||||
case has == ScopeWrite:
|
||||
|
|
@ -103,7 +111,9 @@ func (has Scope) Permits(wanted Scope) bool {
|
|||
return strings.HasPrefix(string(wanted), string(ScopeAdminRead))
|
||||
case has == ScopeAdminWrite:
|
||||
return strings.HasPrefix(string(wanted), string(ScopeAdminWrite))
|
||||
|
||||
// No match.
|
||||
default:
|
||||
return has == wanted
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue