Authenticates user with credentials and returns JWT token with role.

login

Authentication failed, invalid credentials, or malformed response

Process:

  1. Send POST request with credentials to /api/auth/login
  2. Validate response success flag
  3. Extract JWT token from response.data
  4. Decode JWT payload to extract user role
  5. Return token and role for application storage
  • Parameters

    • username: string

      User's login username

    • password: string

      User's login password

    Returns Promise<{
        role: string;
        token: string;
    }>

    JWT token and user role