Authentication
Given an
Write APIs to perform operations on the table
User Table
Column | Type |
---|---|
username | TEXT |
name | TEXT |
password | TEXT |
gender | TEXT |
location | TEXT |
API 1
Path: /register
Method: POST
Request
Scenario 1
Description:
If the username already exists
Response
- Status code
400
- Status text
User already exists
- Status code
Scenario 2
Description:
If the registrant provides a password with less than 5 characters
Response
- Status code
400
- Status text
Password is too short
- Status code
Scenario 3
Description:
Successful registration of the registrant
Response
- Status code
200
- Status text
User created successfully
- Status code
API 2
Path: /login
Method: POST
Request
Scenario 1
Description:
If an unregistered user tries to login
Response
- Status code
400
- Status text
Invalid user
- Status code
Scenario 2
Description:
If the user provides incorrect password
Response
- Status code
400
- Status text
Invalid password
- Status code
Scenario 3
Description:
Successful login of the user
Response
- Status code
200
- Status text
Login success!
- Status code
API 3
Path: /change-password
Method: PUT
Request
Scenario 1
Description:
If the user provides incorrect current password
Response
- Status code
400
- Status text
Invalid current password
- Status code
Scenario 2
Description:
If the user provides new password with less than 5 characters
Response
- Status code
400
- Status text
Password is too short
- Status code
Scenario 3
Description:
Successful password update
Response
- Status code
200
- Status text
Password updated
- Status code
Use
Export the express instance using the default export syntax.
Use Common JS module syntax.