Elaborate documentation concerning roles checks inside authorize function
acrolink opened this issue · 2 comments
acrolink commented
In documentation, an example is given to make role checks inside authorize
function. Kindly, provide more information how to implement the role
field itself, datatype, schema properties etc.
# Admin users can do anything
def authorize(_, %Blog.User{role: :admin}, _), do: :ok
acrolink commented
Update:
I have managed to do this:
def authorize(:list_posts, %User{role: "admin"}, _), do: :ok
I have created a Roles
table with a string field named name
as primary key. But still I need to specify it as "admin"
not :admin
in def authorize(...)
schrockwell commented
Yes, the role field is an implementation detail left to the user. It could be an atom in some cases.