From d895812235bfbf9aea73b792304766f24d38328b Mon Sep 17 00:00:00 2001 From: enlineawork Date: Sat, 5 Sep 2026 20:20:47 -0300 Subject: [PATCH] =?UTF-8?q?F2.2:=20exponer=20endpoints=20de=20autenticaci?= =?UTF-8?q?=C3=B3n=20Android?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api-v3/src/auth/mobile-auth.controller.ts | 56 +++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 api-v3/src/auth/mobile-auth.controller.ts diff --git a/api-v3/src/auth/mobile-auth.controller.ts b/api-v3/src/auth/mobile-auth.controller.ts new file mode 100644 index 0000000..05cad07 --- /dev/null +++ b/api-v3/src/auth/mobile-auth.controller.ts @@ -0,0 +1,56 @@ +import { + Body, + Controller, + HttpCode, + Post, + Req, +} from '@nestjs/common'; +import { Throttle } from '@nestjs/throttler'; +import type { + AuthPrincipal, + RequestWithContext, +} from '../common/http/request-context'; +import { CurrentAuth } from './decorators/current-auth.decorator'; +import { Public } from './decorators/public.decorator'; +import { SkipCsrf } from './decorators/skip-csrf.decorator'; +import { LoginDto } from './dto/login.dto'; +import { MobileRefreshDto } from './dto/mobile-refresh.dto'; +import { MobileAuthService } from './mobile-auth.service'; + +@Controller('auth/mobile') +export class MobileAuthController { + constructor(private readonly mobileAuth: MobileAuthService) {} + + @Post('login') + @HttpCode(200) + @Public() + @SkipCsrf() + @Throttle({ default: { limit: 5, ttl: 60_000, blockDuration: 60_000 } }) + login( + @Body() dto: LoginDto, + @Req() request: RequestWithContext, + ) { + return this.mobileAuth.login(dto, request); + } + + @Post('refresh') + @HttpCode(200) + @Public() + @SkipCsrf() + @Throttle({ default: { limit: 20, ttl: 60_000 } }) + refresh( + @Body() dto: MobileRefreshDto, + @Req() request: RequestWithContext, + ) { + return this.mobileAuth.refresh(dto.refreshToken, request); + } + + @Post('logout') + @HttpCode(200) + logout( + @CurrentAuth() principal: AuthPrincipal, + @Req() request: RequestWithContext, + ) { + return this.mobileAuth.logout(principal, request); + } +}