validate email API

This commit is contained in:
Kallesh B S 2025-06-03 10:43:40 +05:30
parent fd80c8213c
commit 708b731854
2 changed files with 43 additions and 2 deletions

View File

@ -2,7 +2,7 @@ import { Body, Controller, Get, Param, Patch, Post, Query } from '@nestjs/common
import { UserMaintenanceService } from './user-maintenance.service';
import { ApiTags } from '@nestjs/swagger';
import { CreateClientLoginsDTO, CreateSPLoginsDTO, CreateUSCIBLoginsDTO, SPID_CLIENTID_DTO, SPID_EMAIL_DTO } from '../../dto/user-maintenance/user-maintenance.dto';
import { USERID_DTO } from 'src/dto/property.dto';
import { EMAIL_DTO, USERID_DTO } from 'src/dto/property.dto';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
@ApiTags('User Maintenance - Oracle')
@ -62,4 +62,11 @@ export class UserMaintenanceController {
async CreateClientLogins(@Body() body: CreateClientLoginsDTO) {
return await this.userMaintenanceService.CreateClientLogins(body);
}
// validate email
@Get('ValidateEmail/:P_EMAILADDR')
async ValidateEmail(@Param() params: EMAIL_DTO) {
return await this.userMaintenanceService.ValidateEmail(params);
}
}

View File

@ -7,7 +7,7 @@ import {
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import * as oracledb from 'oracledb';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { USERID_DTO } from 'src/dto/property.dto';
import { EMAIL_DTO, USERID_DTO } from 'src/dto/property.dto';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
@ -380,6 +380,40 @@ export class UserMaintenanceService {
await closeOracleDbConnection(connection, UserMaintenanceService.name)
}
}
// validate email
async ValidateEmail(body: EMAIL_DTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
userlogin_pkg.ValidateEmail(
:P_EMAILADDR, :P_CURSOR
);
END;`,
{
P_EMAILADDR: { val: body.P_EMAILADDR, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_CURSOR, UserMaintenanceService.name);
} catch (error) {
handleError(error, UserMaintenanceService.name)
} finally {
await closeOracleDbConnection(connection, UserMaintenanceService.name)
}
}
}