BIO.RE
Authentication

Forgot Password

Request a password reset email. Anti-enumeration — always returns success regardless of account existence.

POST /api/v1/auth/forgot-password — 🌐 Public · Rate limit: 5 req / hour

Initiates the password reset flow. If the email is registered + active, a reset email is queued (worker-service). Returns success even if the account is unknown — anti-enumeration.

Privacy by default: response is 200 OK regardless of whether the email is registered. Client should display a generic "If the address is registered, a reset email has been sent." Do not infer account existence from this response.

Request

Body — ForgotPasswordDto

FieldTypeRequiredValidationNotes
emailstring (RFC 5322)Trimmed + lowercasedLookup against User.email

Response

200 OKApiResponseOf<MessageResponseDto>

{ "success": true, "data": { "message": "Password reset email sent if account exists" } }

Errors

HTTPcode / i18nKeyReason
429(throttle)Rate limit exceeded (5 req/hour — strict to deter enumeration + spam)

Side effects

  1. Lookup User by email; always returns success (anti-enumeration).
  2. If user exists + active + email-verified: invalidate prior PasswordReset records, create new token, queue reset email (worker-service).
  3. Audit log: auth.forgot_password.requested (always logged regardless of account existence).

Code samples

curl -X POST https://api.bio.re/api/v1/auth/forgot-password \
  -H 'Content-Type: application/json' \
  -d '{"email": "[email protected]"}'
async function forgotPassword(email: string): Promise<{ message: string }> {
  const res = await fetch('https://api.bio.re/api/v1/auth/forgot-password', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ email }),
  });
  const json = await res.json();
  if (!res.ok || !json.success) {
    throw Object.assign(new Error(json?.error?.message ?? 'Request failed'), {
      code: json?.error?.code,
    });
  }
  return json.data;
}
import { useMutation } from '@tanstack/react-query';

export function useForgotPassword() {
  return useMutation({
    mutationFn: async (email: string) => {
      const res = await fetch('/api/v1/auth/forgot-password', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ email }),
      });
      const json = await res.json();
      if (!res.ok || !json.success) {
        throw Object.assign(new Error(json?.error?.message ?? 'Request failed'), {
          code: json?.error?.code,
        });
      }
      return json.data;
    },
  });
}

Try it

POST
/api/v1/auth/forgot-password

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

curl -X POST "https://loading/api/v1/auth/forgot-password" \  -H "Content-Type: application/json" \  -d '{    "email": "[email protected]"  }'
{
  "success": true,
  "data": {
    "message": "Operation completed successfully"
  }
}
{
  "success": false,
  "error": {
    "code": "AUTH_UNAUTHORIZED",
    "message": "Invalid credentials",
    "i18nKey": "auth.login.invalid_credentials",
    "i18nVars": {
      "field": "email"
    },
    "details": [
      {
        "message": "email must be an email"
      }
    ],
    "correlationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
  }
}

Source

SourcePathLines
Controllerapps/api-core/src/modules/auth/auth.controller.ts204–212
DTO (request)apps/api-core/src/modules/auth/dto/index.ts108–113 (ForgotPasswordDto)
Serviceapps/api-core/src/modules/auth/auth.service.tsforgotPassword()
Prisma modelspackages/prisma/prisma/schema.prismaUser, PasswordReset

On this page