Skip to content

web-backend


Class: AuthController

Defined in: packages/web-backend/src/auth/auth.controller.ts:15

Controller for authentication endpoints. Provides token issuance and credential verification APIs.

Constructors

Constructor

new AuthController(authService): AuthController

Defined in: packages/web-backend/src/auth/auth.controller.ts:20

Construct the controller with the authentication service.

Parameters

authService

AuthService

Service handling user auth and JWT issuance.

Returns

AuthController

Methods

loginUser()

loginUser(req): Promise<{ token: string; }>

Defined in: packages/web-backend/src/auth/auth.controller.ts:37

Handles user login and returns a JWT token.

Parameters

req

Express request object. See https://expressjs.com/en/api.html#req.

user

User

Returns

Promise<{ token: string; }>

JWT token

Examples

ts
Request body sample:
{
  "username": "Ed",
  "password": "WinryRockbell"
}
ts
POST request: https://staging.app.openpra.org/api/auth/token-obtain

verifyPassword()

verifyPassword(body): Promise<{ match: boolean; }>

Defined in: packages/web-backend/src/auth/auth.controller.ts:54

Verifies if the provided password matches the database for the given user.

Parameters

body

The request should contain two keys: username and password.

password

string

username

string

Returns

Promise<{ match: boolean; }>

Whether the provided password matches for the given username.

Example

ts
Request body example:
{
  "username": "Ed",
  "password": "FullMetalAlchemist"
}