OlegKlimenko / Plamber-Android

The Android application for Plamber project.
https://plamber.com.ua/
Apache License 2.0
1 stars 0 forks source link

Implement ability to login with Email #91

Closed OlegKlimenko closed 5 years ago

OlegKlimenko commented 6 years ago

Implement ability to login with Email

OlegKlimenko commented 6 years ago

I will write changes after will change API endpoints.

OlegKlimenko commented 5 years ago

Implement ability to login with Email

OlegKlimenko commented 5 years ago

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