File

apps/recallassess/recallassess-api/src/api/client/auth/auth.controller.ts

Prefix

api/client/auth

Index

Methods

Methods

Async requestPasswordReset
requestPasswordReset(dto: RequestPasswordResetDto)
Decorators :
@HttpCode(HttpStatus.OK)
@Public()
@Post('request-password-reset')

Request password reset - sends password setup link via email POST /api/client/auth/request-password-reset

Parameters :
Name Type Optional
dto RequestPasswordResetDto No
Returns : Promise<literal type>
Async resendVerification
resendVerification(body: ResendVerificationDto)
Decorators :
@HttpCode(HttpStatus.OK)
@Public()
@Post('resend-verification')

Resend email verification token (public; unverified users have no stable auth context) POST /api/client/auth/resend-verification

Parameters :
Name Type Optional
body ResendVerificationDto No
Returns : Promise<literal type>
Async setPassword
setPassword(dto: SetPasswordDto, auth: CLAuthData)
Decorators :
@HttpCode(HttpStatus.OK)
@Post('set-password')

Set initial password for logged-in participant with no password yet (invited / missing-password flow). POST /api/client/auth/set-password

Parameters :
Name Type Optional
dto SetPasswordDto No
auth CLAuthData No
Returns : Promise<literal type>
Async setupPassword
setupPassword(dto: SetupPasswordDto)
Decorators :
@HttpCode(HttpStatus.OK)
@Public()
@Post('setup-password')

Setup password endpoint for new account setup POST /api/client/auth/setup-password

Parameters :
Name Type Optional
dto SetupPasswordDto No
signIn
signIn(dto: ParticipantSignInDto)
Decorators :
@HttpCode(HttpStatus.OK)
@Public()
@Post('sign-in')

Sign in endpoint for participants POST /api/client/auth/sign-in

Parameters :
Name Type Optional
dto ParticipantSignInDto No
Returns : any
signInWithToken
signInWithToken(dto: SignInWithTokenDto)
Decorators :
@HttpCode(HttpStatus.OK)
@Public()
@Post('sign-in-with-token')

Sign in with token endpoint for participants POST /api/client/auth/sign-in-with-token

Parameters :
Name Type Optional
dto SignInWithTokenDto No
Returns : any
signUp
signUp(dto: ParticipantSignUpDto)
Decorators :
@HttpCode(HttpStatus.CREATED)
@Public()
@Post('sign-up')

Sign up endpoint for participants POST /api/client/auth/sign-up

Parameters :
Name Type Optional
dto ParticipantSignUpDto No
Returns : any
Async validateSetupToken
validateSetupToken(token: string)
Decorators :
@HttpCode(HttpStatus.OK)
@Public()
@Get('validate-setup-token')

Validate password setup token GET /api/client/auth/validate-setup-token?token=...

Parameters :
Name Type Optional
token string No
Returns : Promise<literal type>
Async verifyEmail
verifyEmail(dto: VerifyEmailDto)
Decorators :
@HttpCode(HttpStatus.OK)
@Public()
@Post('verify-email')

Verify email address using verification token POST /api/client/auth/verify-email

Parameters :
Name Type Optional
dto VerifyEmailDto No
Returns : Promise<literal type>
import { CLAuthData, ClientAuth } from "@api/shared/decorators";
import { Public } from "@bish-nest/core/auth/decorator/public.decorator";
import { Body, Controller, Get, HttpCode, HttpStatus, Post, Query } from "@nestjs/common";
import { CLAuthService } from "./auth.service";
import {
  ParticipantSignInDto,
  ParticipantSignUpDto,
  RequestPasswordResetDto,
  ResendVerificationDto,
  SignInWithTokenDto,
  VerifyEmailDto,
} from "./dto";
import {
  SetPasswordDto,
  SetupPasswordDto,
  SetupPasswordResponseDto,
} from "./dto/password-setup.dto";

@Controller("api/client/auth")
export class CLAuthController {
  constructor(private authService: CLAuthService) {}

  /**
   * Sign in endpoint for participants
   * POST /api/client/auth/sign-in
   */
  @HttpCode(HttpStatus.OK)
  @Public()
  @Post("sign-in")
  signIn(@Body() dto: ParticipantSignInDto) {
    return this.authService.signIn(dto);
  }

  /**
   * Sign up endpoint for participants
   * POST /api/client/auth/sign-up
   */
  @HttpCode(HttpStatus.CREATED)
  @Public()
  @Post("sign-up")
  signUp(@Body() dto: ParticipantSignUpDto) {
    return this.authService.signUp(dto);
  }

  /**
   * Sign in with token endpoint for participants
   * POST /api/client/auth/sign-in-with-token
   */
  @HttpCode(HttpStatus.OK)
  @Public()
  @Post("sign-in-with-token")
  signInWithToken(@Body() dto: SignInWithTokenDto) {
    return this.authService.signInWithToken(dto.accessToken);
  }

  /**
   * Setup password endpoint for new account setup
   * POST /api/client/auth/setup-password
   */
  @HttpCode(HttpStatus.OK)
  @Public()
  @Post("setup-password")
  async setupPassword(@Body() dto: SetupPasswordDto): Promise<SetupPasswordResponseDto> {
    return this.authService.setupPassword(dto);
  }

  /**
   * Validate password setup token
   * GET /api/client/auth/validate-setup-token?token=...
   */
  @HttpCode(HttpStatus.OK)
  @Public()
  @Get("validate-setup-token")
  async validateSetupToken(@Query("token") token: string): Promise<{ valid: boolean; message?: string }> {
    return this.authService.validateSetupToken(token);
  }

  /**
   * Set initial password for logged-in participant with no password yet (invited / missing-password flow).
   * POST /api/client/auth/set-password
   */
  @HttpCode(HttpStatus.OK)
  @Post("set-password")
  async setPassword(
    @Body() dto: SetPasswordDto,
    @ClientAuth() auth: CLAuthData,
  ): Promise<{ success: boolean; message: string }> {
    return this.authService.setPasswordForLoggedInUser(auth.participantId, dto.password);
  }

  /**
   * Request password reset - sends password setup link via email
   * POST /api/client/auth/request-password-reset
   */
  @HttpCode(HttpStatus.OK)
  @Public()
  @Post("request-password-reset")
  async requestPasswordReset(
    @Body() dto: RequestPasswordResetDto,
  ): Promise<{ success: boolean; message: string }> {
    return this.authService.requestPasswordReset(dto);
  }

  /**
   * Verify email address using verification token
   * POST /api/client/auth/verify-email
   */
  @HttpCode(HttpStatus.OK)
  @Public()
  @Post("verify-email")
  async verifyEmail(@Body() dto: VerifyEmailDto): Promise<{ success: boolean; message: string }> {
    return this.authService.verifyEmail(dto.token);
  }

  /**
   * Resend email verification token (public; unverified users have no stable auth context)
   * POST /api/client/auth/resend-verification
   */
  @HttpCode(HttpStatus.OK)
  @Public()
  @Post("resend-verification")
  async resendVerification(
    @Body() body: ResendVerificationDto,
  ): Promise<{ success: boolean; message: string }> {
    return this.authService.resendEmailVerification(body.email);
  }
}

results matching ""

    No results matching ""