E_GUEST_ONLY: Only guest user can access the route GET /login

I have enabled guest middlware in some routes.How i can redirect to a certain route when i am authenticated in these routes.

Seems like guest middleware throws error when user is not quest

throw new GE.HttpException(Only guest user can access the route ${request.method()} ${request.url()}, 403, 'E_GUEST_ONLY')

It seems like you should be able to make error handler, catch error, check if it’s E_GUEST_ONLY and then redirect to somewhere

https://adonisjs.com/docs/4.1/exceptions

1 Like