Laravel how to prevent login of users based on extra flag on User model?

Viewed 689

I've implemented email verification schema for default Authentication mechanism of Laravel. However I'm stuck on how to prevent users with unverified emails from logging in.

I can test if user credentials are valid but then I can not retrieve user based on those credentials (Auth::validate).

Alternatively I could use Auth::attempt or Auth::once to log user, but then, they are logged in even though they may have unverified email.

I need either a way to query users by credentials, or a way to log user out in the same request. (bonus points if I can do it in LoginController after validation hook, thus returning proper error notice to user.

1 Answers
Related