Search code examples
authenticationstrapiheadless-cms

Customize Strapi v4 Authentication


I've been working on a Strapi v4 project and would like to customize the authentication flow. Instead of using email as the primary identifier for logging in users, I intend to use a mobile number field that I've added to the user table. I am looking for a way to modify the default Strapi authentication controller to authenticate users with their mobile number and password.

I have successfully set up mobile number validation on my own, so that's not a concern. My main challenge is in changing the authentication logic without altering the existing route ("/auth/local"). I want to retain the endpoint but adjust the internals to accept a mobile number for authentication.

Could you guide me through the necessary steps or point me to the right direction in achieving this customization without introducing a new route?

Thank you for your assistance!

How to Customize Strapi v4 Authentication to Use Mobile Number Instead of Email


Solution

  • so strapi api login works with both username and email, so while signing up you can save your phone number in username, that you need to handle, so you can then login with that