4 weeks ago

Auto-login after registration issue

Posted 4 weeks ago by rpd

I am creating a registration process where, after registering, I'd like a user to verify their email before they can continue. In theory, Fortify should automatically login a user after registration, redirect them to the /dashboard route but then display the verify-email view if the user's email is not verified.

However, what I'm finding is that the user is not being logged in automatically so when trying to access the dashboard page it instead redirects to the login, and I can't work out why.

I tried a dd(Auth::user()) within the store method inside the RegisteredUserController after $this->guard->login($user); and it is returning a logged in user, however somewhere between there and the dashboard page I guess it's not retaining that.

If I do proceed to log in, everything works perfectly, it's just not logging in automatically for me.

I suspect it may be because I've set the user to login using a username rather than email, although I believe I have updated that appropriately in the fortify config file.

Have spent hours scratching my head over this one, any suggestions? Thanks!

Please sign in or create an account to participate in this conversation.