DEV Community

Mahedi Hasan
Mahedi Hasan

Posted on

Laravel Auth: Login With Email Or Username In One Field

A quick amazing tip for you guys. What if in your project users can login not only with email but also with some other field, like “username” or “user_id” or whatever? By default Laravel allows only one field like ’email’. That’s actually easy to change.In this tutorial, we will see how we can login with only two fields login and password. Login can either be email or username.

Let’s imagine that you already have a field username in your users table and need to check the login form result. So there are only two input fields – login and password. And login may be either email or username. How can we check both? In this tutorial now we are going to show how a user can log in using username or password in a one field. Let's see.

https://www.codechief.org/article/laravel-auth-login-with-email-or-username-in-one-field

Top comments (0)