mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 13:40:57 +00:00
feat(auth): add post-Fayda password setup flow
This commit is contained in:
@@ -3,10 +3,10 @@ import { ApiTags, ApiOperation, ApiResponse, ApiBody, ApiBearerAuth } from '@nes
|
||||
import { Throttle, SkipThrottle } from '@nestjs/throttler';
|
||||
import { IsPublic } from '@tria-plc/api-common/modules/auth/decorators/public.decorator';
|
||||
import { PassengerAuthService } from './passenger-auth.service';
|
||||
import { RegisterDto, LoginDto } from './auth.dto';
|
||||
import { RegisterDto, LoginDto, FaydaRequestPasswordSetupDto, FaydaVerifyAndLoginDto } from './auth.dto';
|
||||
import { JwtGuard } from '../../common/jwt.guard';
|
||||
|
||||
@ApiTags('Auth')
|
||||
@ApiTags('Passenger Auth')
|
||||
@Controller('auth')
|
||||
@Throttle({ auth: { limit: 5, ttl: 60_000 } })
|
||||
export class AuthController {
|
||||
@@ -118,4 +118,24 @@ export class AuthController {
|
||||
resetPassword(@Param('id') id: string, @Body() body: { tempPassword: string }) {
|
||||
return this.passengerAuthService.resetUserPassword(id, body.tempPassword);
|
||||
}
|
||||
|
||||
@Post('fayda/request-password-setup')
|
||||
@IsPublic()
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@ApiOperation({ summary: 'Send OTP to phone for Fayda-verified account password setup' })
|
||||
@ApiResponse({ status: 200, description: 'OTP sent to registered phone number' })
|
||||
@ApiBody({ type: FaydaRequestPasswordSetupDto })
|
||||
requestFaydaPasswordSetup(@Body() dto: FaydaRequestPasswordSetupDto, @Request() req: any) {
|
||||
return this.passengerAuthService.requestFaydaPasswordSetup(dto.phoneNumber, req);
|
||||
}
|
||||
|
||||
@Post('fayda/verify-and-login')
|
||||
@IsPublic()
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@ApiOperation({ summary: 'Verify OTP and receive session token for Fayda-verified account' })
|
||||
@ApiResponse({ status: 200, description: 'Returns token + requiresPassword flag. Use token with POST /v1/auth/set-fayda-password.' })
|
||||
@ApiBody({ type: FaydaVerifyAndLoginDto })
|
||||
verifyFaydaAndLogin(@Body() dto: FaydaVerifyAndLoginDto) {
|
||||
return this.passengerAuthService.verifyFaydaAndLogin(dto.phoneNumber, dto.otp);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user