Comment

Comment by chejazi

You can stuff the logic of "who can do what" somewhere else. eg:

var permissions = { "Superadmin": ["selfdestruct",...], "Admin": ["ban",...], "Plebe": ["post",...] };

function roleCanDo(action, role) { return permissions[role].indexOf(action) > -1; }

Your check would look like: if (roleCanDo("someaction", user.getRole()))

Sorry if JS isn't your thing.

parent chejazi 10 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton