Description
Context
Note: work on this issue after codebuddies/backend#187 is merged in. That PR rewrote the auth to use a more up-to-date auth package that supports email verification, an important step we didn't support before.
First, let me try registering a new user:
POST /api/v1/auth/registration/
{
"username": "linda",
"email": "youremail@gmail.com",
"password1": "uniquepassword",
"password2": "uniquepassword"
}
I'll get a 201 Response:
{
"detail": "Verification e-mail sent."
}
If I login without verifying the email, I'll get the following 400 response:
POST /api/v1/auth/login/
{
"username": "",
"email": "",
"password": ""
}
HTTP 400 Bad Request
Allow: POST, OPTIONS
Content-Type: application/json
Vary: Accept
{
"non_field_errors": [
"E-mail is not verified."
]
}
When the verification email is sent, it'll contain a link that looks something like:
http://localhost:8000/api/v1/auth/registration/verify-email/?key=
On the FE app, we'll need to create a page with the route /api/v1/auth/registration/verify-email/?key=
and make a POST request sending the key:
POST /api/v1/auth/registration/verify-email/
{
"key":
}
This will validate the email address.
Source: codebuddies/backend#191
How to log out:
POST api/v1/auth/logout
How to view the details of a currently-logged-in user
GET api/v1/auth/user
GET api/v1/auth/current_user //without email address
Acceptance criteria
[ ] Update the POST request when a user registers to hit POST /api/v1/auth/registration/
[ ] Remove the first name and last name fields
[ ] Change the login endpoint to be POST /api/v1/auth/login/
[ ] Change the logout endpoint to be POST api/v1/auth/logout
[ ] Create a api/v1/auth/registration/verify-email?key={KEY} page that upon load, makes a POST request to /verify-email and passes in the key from the params in the URL
POST /api/v1/auth/registration/verify-email/
{
"key": <KEY>
}