I have a problem in my middleware.
Created custom middleware: php artisan AuthNew
Inside my AuthNew:
Inside my routes.php:
The problem is when I login it always redirect me to /account. Even if I do /logout thing it will still redirect me to /account. What I expect to happen is when I successfully login. All account routes will only routes if user is authenticated. and if not will redirect me to login page. And will not anymore access the /account link. vice versa with login. (if authenticated can't access the login page) Please advise.
You apply your middleware to all routes in that route group, including /postLogin. Route middleware is run before controller is executed. When you try to login you are recognized as guest and therefore redirected to /account before /postLogin is executed. Declare /postLogin route outside that group so that middleware is not applied.