Closed OlegKlimenko closed 5 years ago
Implement ability to login with Email
I will write changes after will change API endpoints.
Implementation notes: A user must have the ability to login with email from the application. There is a need to have validation on the app side to divide sending email or username
The API endpoint will be the same as in our current implementation:
<host>/api/v1/user-login/
Request parameters are the same as previous but in "username" param you can put username or email:
{"app_key": "<app key>",
"username": "<username>",
"password": "<password>"}
There are validation on the server side of possible username passed. First it tries email regex and then username. If it not matches to possible values the response will be as:
{"detail": "<validation_errors>", "data": {}}
With status 400 - Bad request in the headers.
After validation passes successfully there is an attempt to authenticate with email or username and the password.
If no matches found the response will be:
{"detail": "not authenticated", "data": {"token": null/false}}
With 404 status - Not found.
If success the data will be provided as in our current implementation:
{"detail": "successful", "data": {"token": "<user_token>"}}
p.s. please, pay attention as many as I remember you said that you have the same forms for login and registration, so after you finish the implementation, please check if you didn't broke the register actions