RestAuth v0.9.0 RestAuth.Restrict View Source

RestAuth.Restrict is where the magic happens.

Sample usage:

  @rest_auth_roles  [
                      {:index, ["user"]},
                      {:create, ["admin"]},
                      {:update, ["admin"]},
                      {:show, ["admin"]},
                      {:delete, ["admin"]}
                     ]
  plug RestAuth.Restrict @rest_auth_roles

In this sample usage I have simply listed the roles in an attribute for readability. The parameter has to be a keyword list of string lists. {:create, "admin"} will not work.

Link to this section Summary

Functions

If plug is called without for example roles: ["user", "admin"], default role from config will be used

Checks given roles against current user

Required initiation method

Link to this section Functions

If plug is called without for example roles: ["user", "admin"], default role from config will be used

Checks given roles against current user.

Required initiation method