riverrun / openmaize

No longer maintained - was an Authentication library for Plug-based applications in Elixir
Other
206 stars 30 forks source link

Checking for authentication #73

Closed alzearafat closed 7 years ago

alzearafat commented 7 years ago

Hi @riverrun

Thanks a lot for great yet simple lib :) I have an question, how I can restrict some controller/routes only for authenticated user?

Maybe something like this?

defmodule MyAwesomeApp.PageController do
  use Phoenix.Controller

  plug Openmaize.Authenticated when action != :index

 # ...

end

Thank you in advance for any help you can provide :) Regards

riverrun commented 7 years ago

You can use when not action in [:index], so the plug command would be:

plug Openmaize.Authenticate when not action in [:index]

If you have any further questions, just let me know.