Skip to content
Curtiss02 edited this page Apr 10, 2020 · 7 revisions

1. /api/User/login

Method: POST

Description: This method is used to login (be allocated a JWT token) a user with the specified username and password

Body Input

Parameters Format
login LoginDTO Object

Request Body example

{
    "username": "string"
    "password": "string"
}

Response

example request URL: https://localhost:5001/api/User/login

STATUS CODE: 404 NOT FOUND No username exists

STATUS CODE: 403 FORBIDDEN Incorrect password

STATUS CODE: 200 OK Successful login

{
    "userName": "string",
    "token": "<JWT token here>"
}

2. /api/User/resetTokenCheck

Method: POST

Description: Confirm if the given reset password token for a user is valid

Body Input

Parameters Format
resetPassword ResetPasswordDTO Object

Request Body example

{
    "email": "string"
    "resetToken": "<reset token here>"
}

Response

example request URL: https://localhost:5001/api/User/resetTokenCheck

STATUS CODE: 400 Bad Request No reset token exists

STATUS CODE: 200 OK Reset token exists

3. /api/User/resetPassWord

Method: POST

Description: Update the given user's password

Body Input

Parameters Format
login LoginDto Object

Request Body example

{
    "email": "string"
    "password": "string"
}

Response

example request URL: https://localhost:5001/api/User/resetPassWord

STATUS CODE: 404 NOT FOUND No username exists

STATUS CODE: 400 BAD REQUEST User does not have valid password change request

STATUS CODE: 200 OK Password successfully reset

4. /api/User/forgotPassword

Method: POST

Description: Send reset password link to user's E-mail

Body Input

Parameters Format
forgotPass ForgotPassRequestDTO Object

Request Body example

{
    "userOrEmail": "string"
}

Response

example request URL: https://localhost:5001/api/User/forgotPassword

STATUS CODE: 404 NOT FOUND Invalid username/email sent

STATUS CODE: 200 OK

{
    "email": "string",
    "resetToken": "<Password reset token>"
}

5. /api/User/check

Method: POST

Description: Checks if an account with the specified username or email exists

Body Input

Parameters Format
registerRequest RegisterRequestDTO Object

Request Body examples

{
    "userName": "string"
    "email": "string"
}

Response

example request URL: https://localhost:5001/api/User/check

STATUS CODE: 400 BAD REQUEST username already exists

STATUS CODE: 409 CONFLICT email already exists

STATUS CODE: 200 OK username and password available

6. /api/User/register

Method: POST

Description: Registers a user with the specified parameters

Body Input

Parameters Format
registerRequest RegisterRequestDTO Object

Request Body examples

{
    "userName": "string",
    "firstName": "string",
    "lastName": "string",
    "dateOfBirth": "2020-03-16T04:25:50.783Z",
    "phoneNumber": "0",
    "email": "string",
    "medicalInformation": "string",
    "bankAccount": "string",
    "password": "string"
}

Response

example request URL: https://localhost:5001/api/User/register

STATUS CODE: 400 BAD REQUEST username, email, phoneNumber or password are strings empty

STATUS CODE: 409 CONFLICT username, email or phoneNumber already used in database

STATUS CODE: 200 OK account was created

{
    "userName": "string",
    "token": "<JWT token here>"
}

7. /api/User/getCurrentUserID

Method: GET

Description: This method is used to get the user id that is associated with a user that is currently logged in

Response

example request URL: https://localhost:5001/api/User/getCurrentUserID

STATUS CODE: 200

{
    "id": 1000,
  },

STATUS CODE: 401 UNAUTHORIZED No user is currently logged in

8. /api/User/getUserIdsByUsername

Method: GET

Description: This method is used to get the users ids based on the usernames. The API expects a JSON object with usernames as keys. Returns a JSON object with usernames and their ids as key/value pairs. If a username was not found, it is assigned a value of "0".

Response

example request URL: https://localhost:5001/api/User/getUsersIds

STATUS CODE: 200

{
    "TestUser1": "998",
    "Non-existing User": "0"
  },

9. /api/User/getUserInfo

Method: GET

Description: Gets the information of the currently logged in user

Response

example request URL: https://localhost:5001/api/User/getUserInfo

STATUS CODE: 200

{
    "id": "string",
    "userName": "string",
    "firstName": "string",
    "lastName": "string",
    "dateOfBirth": "2020-03-16T04:25:50.783Z",
    "phoneNumber": "0",
    "email": "string",
    "medicalInformation": "string",
    "bankAccount": "string"
}

STATUS CODE: 401 UNAUTHORIZED No user is currently logged in

10. /api/User/editUserInfo

Method: POST

Description: Updates the account details of the currently logged in user

Body Input

Parameters Format
info EditUserDTO Object

Request Body example

{
    "firstName": "string",
    "lastName": "string",
    "dateOfBirth": "2020-03-16T04:25:50.783Z",
    "phoneNumber": "0",
    "email": "string",
    "medicalInformation": "string",
    "bankAccount": "string"
}

Response

example request URL: https://localhost:5001/api/User/editUserInfo

STATUS CODE: 200 Success STATUS CODE: 400 Failed

Clone this wiki locally