Fix fetching permissions from db