VERIFICATION

REST API Endpoints

Middleware

When a user makes an HTTPS request, session middleware checks the token. Using that token, we determine if a route is accessible to the current user, as some routes might be public or session-based

1. User Login

  • HTTP Request Type: POST

  • Route: /firestapi/account/login

  • URL / Body Parameters:

    • email: String

    • password: String

  • Info: This endpoint logs a user in based on the email and password. If login is successful, a token is received and set as a browser cookie to be authenticated on every request.

HTTPS Body Example:

json

{ 
"email": "runzho.li@fundamentalinteractions.com", "password": "Test123!" 
}

2. User Logout

  • HTTP Request Type: POST

  • Route: /firestapi/account/logout

  • URL / Body Parameters: None

  • Info: This endpoint deletes the token cookie if it exists.

3. Check Login Status

  • HTTP Request Type: GET

  • Route: /firestapi/account

  • URL / Body Parameters: None

  • Info: This endpoint checks if the user is logged in or not

Example Implementation in Express.js

Here's an example of how you might implement these endpoints in an Express.js application:

javascript

This example sets up the three specified routes using Express.js, handles user login by setting a session token and cookie, checks login status, and provides a logout endpoint to clear the session and token cookie.

Last updated