Quantcast
Channel: How to restrict access to certain routes in Phoenix? - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Jason Harrelson for How to restrict access to certain routes in Phoenix?

$
0
0

You could also define a separate pipeline for the authenticated endpoints:

defmodule MyApp.Router do  use MyApp.Web, :router  pipeline :admin do     plug :accepts, ["html"]    plug Authentication # this represents some plug that provides authentication  end  scope "/", MyApp do    pipe_through :browser    resources "/things", ThingController  end  scope "/admin", MyApp do    pipe_through :admin    resources "/admin/things", Admin.ThingsController  endend

The admin scope is just an example, it can be anything you like, but the pipeline idea remains consistent.

This technique will keep your controllers cleaner, but is not always possible. It depends on your exact requirements.


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>