James Erikson
James Erikson

Reputation: 63

1 route, 2 different views Laravel 9

I'm trying to accomplish what facebook does

When you go to facebook, you're greeted with the login page at the / route

Once logged in, you're now greeted with the newsfeed, but still at the / route

I also need to be able to attach the verified middleware to the auth side

I tried making a HomeController and putting:

if(Auth::check()) {
//return dashboard view
}else{
//return guest view
}

This works, but I have no way to force email verification or any other middlewares other than the general auth middleware. If I attach the verified auth on the / route, it obviously forces that for both guest and auth

Thank you

Upvotes: 0

Views: 146

Answers (1)

James Erikson
James Erikson

Reputation: 63

For anyone else trying to do similar, I found out I can achieve this by putting the following line into the HomeController:

if(Auth::user()->email_verified_at == null){
return view('auth.verify-email');
}

Upvotes: 0

Related Questions