I have two users, Buyer and Admin in my app, they both have different login details, admin logs in with email and password, buyer logs in with their phone number and a code we send them. So, I made two authentication plugs. Here is how I have added the plugs to my browser pipeline:
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug Phoenix.LiveView.Flash
plug :protect_from_forgery
plug :put_secure_browser_headers
plug AffirmWeb.BuyerAuth
plug AffirmWeb.AdminAuth
end
So here is the problem, when the admin logs in, they get the login menu and they can access all the other pages. When the buyer logs in, I can see from the logs(I IO.inspect the conn so I know they are logged in), they still get the "signed out" menu, they also cannot access some pages. If I change the piping order to have AffirmWeb.BuyerAuth comes last, now the buyer can access other pages and admin cannot. Any guidance on how I can go about this?