meow
More progress. Fixed storage bug. Need to get media stuff going
This commit is contained in:
parent
1bb6cd8a70
commit
83f47d17be
11 changed files with 209 additions and 27 deletions
|
@ -27,6 +27,11 @@ func StorageFromRequest(r *http.Request) *storage.Storage {
|
|||
return store
|
||||
}
|
||||
|
||||
func ActorIdFromRequest(r *http.Request) (string, bool) {
|
||||
id, ok := r.Context().Value(ContextKeyActorId).(string)
|
||||
return id, ok
|
||||
}
|
||||
|
||||
func NoteIdFromRequest(r *http.Request) string {
|
||||
return r.PathValue("noteId")
|
||||
}
|
||||
|
@ -34,3 +39,16 @@ func NoteIdFromRequest(r *http.Request) string {
|
|||
func AccountIdFromRequest(r *http.Request) string {
|
||||
return r.PathValue("accountId")
|
||||
}
|
||||
|
||||
func CheckIfAccountIdHasPermissions(accId string, perms storage.Role, store *storage.Storage) bool {
|
||||
acc, err := store.FindAccountById(accId)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
roles, err := store.FindRolesByNames(acc.Roles)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
collapsed := storage.CollapseRolesIntoOne(roles...)
|
||||
return storage.CompareRoles(&collapsed, &perms)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue