Restrict access to some routes by session

Hi guys!

I want to restrict some routes, by example /admin for non-admin users and etc.

By example, in express.js and laravel I can make this with middlewares.

But how to implement this in phoenix I don’t have idea.

Thanks in advance :wink:


This would be done by plug in Phoenix. Basically, You add info to connection assigns after successful login, then plugs will check for this info.

You can have a look at guardian, to see how it manages this.