auth template modified for dev testing
This commit is contained in:
parent
fcb8b6e428
commit
8b964d2c84
278
api.http
278
api.http
@ -1,266 +1,72 @@
|
||||
// InsertRegions
|
||||
GET http://192.168.1.96:3006
|
||||
|
||||
POST http://localhost:3000/oracle/InsertRegions
|
||||
###
|
||||
|
||||
GET http://localhost:3006
|
||||
|
||||
###
|
||||
|
||||
POST http://localhost:3006/sendmail/b@gmail.com
|
||||
|
||||
###
|
||||
|
||||
GET http://localhost:3006/GetUserDetails/d@gmail.com
|
||||
|
||||
###
|
||||
|
||||
GET http://localhost:3006/GetUserDetail/d@gmail.com
|
||||
|
||||
###
|
||||
|
||||
GET http://localhost:3006/GetSP
|
||||
|
||||
###
|
||||
|
||||
GET http://localhost:3006/checkroles
|
||||
|
||||
###
|
||||
|
||||
POST http://localhost:3006/login-client
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"p_region":"p_region",
|
||||
"p_name":"p_name"
|
||||
"P_EMAILADDR":"a@gmail.com",
|
||||
"P_PASSWORD":"A1!bcdef"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
//UpdateRegion
|
||||
POST http://localhost:3006/logout-client
|
||||
|
||||
PATCH http://localhost:3000/oracle/UpdateRegion
|
||||
###
|
||||
|
||||
POST http://localhost:3006/register
|
||||
Content-Type: application/json
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImJAZ21haWwuY29tIiwiaWF0IjoxNzUwMTM3NTc4LCJleHAiOjE3NTAxNDExNzh9.ooNhATybtRY_HORWBH0vBLzPODxOWZMi3Q_cvS7kAho
|
||||
|
||||
{
|
||||
"p_regionID": ,
|
||||
"p_name":"p_name"
|
||||
"email":"b@gmail.com",
|
||||
"password":"B1!bcdef"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
// GetRegions
|
||||
|
||||
GET http://localhost:3000/oracle/GetRegions
|
||||
GET http://localhost:3006/getrole/ca
|
||||
|
||||
###
|
||||
|
||||
PUT http://localhost:3006/forgot-password
|
||||
|
||||
//InsertNewServiceProvider
|
||||
|
||||
POST http://localhost:3000/oracle/InsertNewServiceProvider
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"p_name": "Service Provider Name",
|
||||
"p_lookupcode": "SP001",
|
||||
"p_address1": "123 Main St",
|
||||
"p_address2": "Suite 100",
|
||||
"p_city": "Anytown",
|
||||
"p_state": "CA",
|
||||
"p_zip": "90210",
|
||||
"p_country": "USA",
|
||||
"p_issuingregion": "Region A",
|
||||
"p_replacementregion": "Region B",
|
||||
"p_bondsurety": "Surety Co.",
|
||||
"p_cargopolicyno": "CP123456",
|
||||
"p_cargosurety": "Cargo Surety Co.",
|
||||
"p_user_id": "user123"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
|
||||
//UpdateServiceProvider
|
||||
|
||||
PUT http://localhost:3000/oracle/UpdateServiceProvider
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"p_spid": 1,
|
||||
"p_name": "Service Provider Name",
|
||||
"p_lookupcode": "SP001",
|
||||
"p_address1": "123 Main St",
|
||||
"p_address2": "Suite 100",
|
||||
"p_city": "Anytown",
|
||||
"p_state": "CA",
|
||||
"p_zip": "90210",
|
||||
"p_country": "USA",
|
||||
"p_issuingregion": "Region A",
|
||||
"p_replacementregion": "Region B",
|
||||
"p_bondsurety": "Surety Co.",
|
||||
"p_cargopolicyno": "CP123456",
|
||||
"p_cargosurety": "Cargo Surety Co.",
|
||||
"p_user_id": "user123"
|
||||
}
|
||||
POST http://localhost:3006/logout-user
|
||||
|
||||
###
|
||||
|
||||
// GetAllServiceproviders
|
||||
|
||||
GET http://localhost:3000/oracle/GetAllServiceproviders
|
||||
GET http://localhost:3006/ref-tok
|
||||
|
||||
###
|
||||
|
||||
//GetSelectedServiceprovider
|
||||
|
||||
GET http://localhost:3000/oracle/GetSelectedServiceprovider/12
|
||||
|
||||
###
|
||||
|
||||
//InsertSPContacts
|
||||
|
||||
POST http://localhost:3000/oracle/InsertSPContacts
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"p_spid": 12345,
|
||||
"p_defcontactflag":"N",
|
||||
"p_firstname": "John",
|
||||
"p_lastname": "Doe",
|
||||
"p_title": "Mr.",
|
||||
"p_phoneno": "123-456-7890",
|
||||
"p_mobileno": "098-765-4321",
|
||||
"p_faxno": "123-456-7891",
|
||||
"p_emailaddress": "john.doe@example.com",
|
||||
"p_user_id": "jdoe"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
//SetSPDefaultcontact
|
||||
|
||||
POST http://localhost:3000/oracle/SetSPDefaultcontact/12
|
||||
|
||||
###
|
||||
|
||||
//UpdateSPContacts
|
||||
|
||||
PUT http://localhost:3000/oracle/UpdateSPContacts
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"p_spcontactid": 12345,
|
||||
"p_firstname": "Jane",
|
||||
"p_lastname": "Doe",
|
||||
"p_title": "Ms.",
|
||||
"p_phoneno": "123-456-7890",
|
||||
"p_mobileno": "098-765-4321",
|
||||
"p_faxno": "123-456-7891",
|
||||
"p_emailaddress": "jane.doe@example.com",
|
||||
"p_user_id": "jdoe"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
|
||||
//InactivateSPContact
|
||||
|
||||
POST http://localhost:3000/oracle/InactivateSPContact/12
|
||||
|
||||
###
|
||||
|
||||
//GetSPDefaultcontact
|
||||
|
||||
GET http://localhost:3000/oracle/GetSPDefaultcontact/12
|
||||
|
||||
###
|
||||
|
||||
//GetAllSPcontacts
|
||||
|
||||
//GET http://localhost:3000/oracle/GetAllSPcontacts
|
||||
|
||||
###
|
||||
|
||||
//CreateCarnetSequence
|
||||
|
||||
POST http://localhost:3000/oracle/CreateCarnetSequence
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"p_spid": 2,
|
||||
"p_regionid": 81,
|
||||
"p_startnumber": 2000,
|
||||
"p_endnumber": 3000,
|
||||
"p_carnettype": "original"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
//GetCarnetSequence
|
||||
|
||||
GET http://localhost:3000/oracle/GetCarnetSequence/12
|
||||
|
||||
###
|
||||
|
||||
//GetParamValues
|
||||
|
||||
GET http://localhost:3000/oracle/GetParamValues?id=500&type=original
|
||||
|
||||
###
|
||||
|
||||
|
||||
//CreateTableRecord
|
||||
|
||||
POST http://localhost:3000/oracle/CreateTableRecord
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"P_USERID": "6",
|
||||
"P_TABLEFULLDESC": "TypeA desc"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
//CreateParamRecord
|
||||
|
||||
POST http://localhost:3000/oracle/CreateParamRecord
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
# "P_SPID": 4,
|
||||
"P_PARAMTYPE": "TypeA",
|
||||
"P_PARAMDESC": "Description of the parameter",
|
||||
"P_PARAMVALUE": "Value of the parameter",
|
||||
# "P_ADDLPARAMVALUE1": "Additional Value 1",
|
||||
# "P_ADDLPARAMVALUE2": "Additional Value 2",
|
||||
# "P_ADDLPARAMVALUE3": null,
|
||||
# "P_ADDLPARAMVALUE4": "Additional Value 4",
|
||||
# "P_ADDLPARAMVALUE5": null,
|
||||
"P_SORTSEQ": 1,
|
||||
"P_USERID": "12"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
// UpdateParamRecord
|
||||
|
||||
PATCH http://localhost:3000/oracle/UpdateParamRecord
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"P_SPID": 2,
|
||||
"P_PARAMID": 1,
|
||||
"P_PARAMDESC": "abc",
|
||||
"P_ADDLPARAMVALUE1": "asd",
|
||||
"P_ADDLPARAMVALUE2": "ad",
|
||||
"P_ADDLPARAMVALUE3": null,
|
||||
"P_ADDLPARAMVALUE4": "asd",
|
||||
"P_ADDLPARAMVALUE5": null,
|
||||
"P_SORTSEQ": 1,
|
||||
"P_USERID": "12"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
// InActivateParamRecord
|
||||
|
||||
PATCH http://localhost:3000/oracle/InActivateParamRecord?pid=1&uid=2
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"P_PARAMID":2,
|
||||
"P_USERID":"12"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
// ReActivateParamRecord
|
||||
|
||||
PATCH http://localhost:3000/oracle/ReActivateParamRecord?pid=1&uid=2
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"P_PARAMID":2,
|
||||
"P_USERID":"12"
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GET http://localhost:3006/ref
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
import { Body, Controller, Get, HttpCode, Post, Put, Req, Res } from '@nestjs/common';
|
||||
import { Body, Controller, Get, HttpCode, Post, Put, Req, Res, UseInterceptors } from '@nestjs/common';
|
||||
import { AuthService } from './auth.service';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { AuthLoginDTO } from './auth.dto';
|
||||
import { Request, Response } from 'express';
|
||||
import { LogoutInterceptor } from 'src/interceptors/logout.interceptor';
|
||||
|
||||
@ApiTags('Auth')
|
||||
@Controller()
|
||||
export class AuthController {
|
||||
constructor(private readonly authService: AuthService) { }
|
||||
|
||||
@ApiTags('Auth')
|
||||
@Post('/login')
|
||||
login(@Body() body: AuthLoginDTO) {
|
||||
return this.authService.login(body);
|
||||
}
|
||||
|
||||
@Post('login-client')
|
||||
// @Post('/login')
|
||||
// login(@Body() body: AuthLoginDTO) {
|
||||
// return this.authService.login(body);
|
||||
// }
|
||||
|
||||
@Post('login')
|
||||
@HttpCode(200)
|
||||
async loginClient(@Body() body: AuthLoginDTO, @Res({ passthrough: true }) res: Response, @Req() req: Request) {
|
||||
let k: any = await this.authService.loginUser(body.P_EMAILADDR, body.P_PASSWORD, req);
|
||||
@ -22,8 +24,8 @@ export class AuthController {
|
||||
if (k.access_token) {
|
||||
res.cookie('access_token', k.access_token, {
|
||||
httpOnly: true,
|
||||
secure: false, // set to true if you're on HTTPS
|
||||
sameSite: 'lax', // adjust based on your needs (strict, lax , none)
|
||||
secure: true, // set to true if you're on HTTPS
|
||||
sameSite: 'none', // adjust based on your needs (strict, lax , none)
|
||||
maxAge: 90 * 1000, // convert seconds to ms if applicable
|
||||
});
|
||||
}
|
||||
@ -31,8 +33,8 @@ export class AuthController {
|
||||
if (k.refresh_token) {
|
||||
res.cookie('refresh_token', k.refresh_token, {
|
||||
httpOnly: true,
|
||||
secure: false, // set to true if you're on HTTPS
|
||||
sameSite: 'lax', // adjust based on your needs (strict, lax , none)
|
||||
secure: true, // set to true if you're on HTTPS
|
||||
sameSite: 'none', // adjust based on your needs (strict, lax , none)
|
||||
maxAge: 90 * 1000, // convert seconds to ms if applicable
|
||||
});
|
||||
}
|
||||
@ -41,14 +43,14 @@ export class AuthController {
|
||||
}
|
||||
|
||||
// @UseGuards(RegisterGuard)
|
||||
@Post('register-client')
|
||||
@Post('register')
|
||||
async register(@Body() body: AuthLoginDTO, @Req() req: Request) {
|
||||
return this.authService.registerUser(body, req);
|
||||
}
|
||||
|
||||
// @UseInterceptors(LogoutInterceptor)
|
||||
@UseInterceptors(LogoutInterceptor)
|
||||
@HttpCode(200)
|
||||
@Post('logout-client')
|
||||
@Post('logout')
|
||||
async logout(@Req() req: any, @Res() res: Response) {
|
||||
const refreshToken = req.user?.refreshToken;
|
||||
let rst: any = await this.authService.logoutUser(refreshToken);
|
||||
@ -59,20 +61,20 @@ export class AuthController {
|
||||
res.json({ ...rst })
|
||||
}
|
||||
|
||||
@Put('forgot-password-client')
|
||||
@Put('forgot-password')
|
||||
async forgotPassword() {
|
||||
return this.authService.forgotPassword();
|
||||
}
|
||||
|
||||
@Get('refresh-client-tokens')
|
||||
@Get('refresh-tokens')
|
||||
async getTokenFromRefreshToken(@Req() req: Request, @Res({ passthrough: true }) res: Response) {
|
||||
let k: any = await this.authService.getTokenFromRefreshToken(req)
|
||||
|
||||
if (k.access_token) {
|
||||
res.cookie('access_token', k.access_token, {
|
||||
httpOnly: true,
|
||||
secure: false, // set to true if you're on HTTPS
|
||||
sameSite: 'lax', // adjust based on your needs (strict, lax , none)
|
||||
secure: true, // set to true if you're on HTTPS
|
||||
sameSite: 'none', // adjust based on your needs (strict, lax , none)
|
||||
maxAge: 90 * 1000, // convert seconds to ms if applicable
|
||||
path: '/'
|
||||
});
|
||||
@ -81,8 +83,8 @@ export class AuthController {
|
||||
if (k.refresh_token) {
|
||||
res.cookie('refresh_token', k.refresh_token, {
|
||||
httpOnly: true,
|
||||
secure: false, // set to true if you're on HTTPS
|
||||
sameSite: 'lax', // adjust based on your needs (strict, lax , none)
|
||||
secure: true, // set to true if you're on HTTPS
|
||||
sameSite: 'none', // adjust based on your needs (strict, lax , none)
|
||||
maxAge: 90 * 1000, // convert seconds to ms if applicable
|
||||
path: '/'
|
||||
});
|
||||
|
||||
@ -7,5 +7,6 @@ import { DbModule } from 'src/db/db.module';
|
||||
imports: [DbModule],
|
||||
providers: [AuthService],
|
||||
controllers: [AuthController],
|
||||
exports: [AuthService]
|
||||
})
|
||||
export class AuthModule {}
|
||||
export class AuthModule { }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BadRequestException, Injectable, InternalServerErrorException } from '@nestjs/common';
|
||||
import { Injectable, InternalServerErrorException } from '@nestjs/common';
|
||||
import { OracleDBService } from 'src/db/db.service';
|
||||
import { AuthLoginDTO } from './auth.dto';
|
||||
import * as oracledb from 'oracledb';
|
||||
@ -9,6 +9,7 @@ import * as jwkToPem from "jwk-to-pem"
|
||||
import * as jwt from "jsonwebtoken"
|
||||
import { UnauthorizedException } from 'src/exceptions/unauthorized.exception';
|
||||
import { ConflictException } from 'src/exceptions/conflict.exception';
|
||||
import { BadRequestException } from 'src/exceptions/badRequest.exception';
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
@ -98,17 +99,15 @@ export class AuthService {
|
||||
|
||||
await cursor.close();
|
||||
} else {
|
||||
throw new BadRequestException({
|
||||
Error: 'Error executing request try after some time!',
|
||||
});
|
||||
throw new BadRequestException('Error executing request try after some time!');
|
||||
}
|
||||
|
||||
if (rows[0]['ERRORMESG']) {
|
||||
throw new BadRequestException({ error: 'Invalid username or password!' });
|
||||
throw new BadRequestException('Invalid username or password!');
|
||||
}
|
||||
return { msg: 'Logged in successfully' };
|
||||
} catch (err) {
|
||||
throw new BadRequestException({ error: 'Invalid username or password' });
|
||||
throw new BadRequestException('Invalid username or password');
|
||||
}
|
||||
finally {
|
||||
if (connection) {
|
||||
@ -157,6 +156,8 @@ export class AuthService {
|
||||
|
||||
const introspection = await this.introspectToken(token);
|
||||
|
||||
console.log("introspection : ", introspection.active, " : so Unauthorized!");
|
||||
|
||||
if (!introspection.active) {
|
||||
throw new Error('Unauthorized');
|
||||
}
|
||||
@ -188,34 +189,34 @@ export class AuthService {
|
||||
const accessToken = req.cookies['access_token'];
|
||||
const refreshToken = req.cookies['refresh_token'];
|
||||
|
||||
if (!accessToken && !refreshToken) {
|
||||
// if (!accessToken && !refreshToken) {
|
||||
|
||||
const params = new URLSearchParams();
|
||||
params.append('grant_type', 'password');
|
||||
params.append('client_id', this.CLIENT_ID);
|
||||
params.append('client_secret', this.CLIENT_SECRET);
|
||||
params.append('username', username);
|
||||
params.append('password', password);
|
||||
const params = new URLSearchParams();
|
||||
params.append('grant_type', 'password');
|
||||
params.append('client_id', this.CLIENT_ID);
|
||||
params.append('client_secret', this.CLIENT_SECRET);
|
||||
params.append('username', username);
|
||||
params.append('password', password);
|
||||
|
||||
try {
|
||||
const response = await axios.post(this.TOKEN_URL, params, {
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
});
|
||||
console.log('first time data ...');
|
||||
try {
|
||||
const response = await axios.post(this.TOKEN_URL, params, {
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
});
|
||||
console.log('first time data ...');
|
||||
|
||||
let k = { ...response.data, email: username };
|
||||
let k = { ...response.data, email: username };
|
||||
|
||||
return k;
|
||||
} catch (error) {
|
||||
console.log(error.message);
|
||||
return k;
|
||||
} catch (error) {
|
||||
console.log(error.message);
|
||||
|
||||
throw new BadRequestException('Invalid username or password');
|
||||
}
|
||||
throw new BadRequestException('Invalid username or password');
|
||||
}
|
||||
// }
|
||||
|
||||
else if (accessToken && refreshToken) {
|
||||
return { access_token: accessToken, refresh_token: refreshToken, email: username }
|
||||
}
|
||||
// else if (accessToken && refreshToken) {
|
||||
// return { access_token: accessToken, refresh_token: refreshToken, email: username }
|
||||
// }
|
||||
}
|
||||
|
||||
async getUserIdByEmail(email: string) {
|
||||
@ -385,7 +386,7 @@ export class AuthService {
|
||||
});
|
||||
return { statusCode: 200, message: 'Logged-Out successfully' };
|
||||
} catch (error) {
|
||||
throw new UnauthorizedException('Logout failed');
|
||||
throw new InternalServerErrorException('Logout failed');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ export class JwtAuthGuard implements CanActivate {
|
||||
request.user = decoded;
|
||||
return true;
|
||||
} catch (err) {
|
||||
console.log(err.message);
|
||||
console.log("error in jwt-auth guard below decode : ",err.message);
|
||||
|
||||
throw new UnauthorizedException({
|
||||
message: 'Invalid Token',
|
||||
|
||||
48
src/guards/roles.guard.ts
Normal file
48
src/guards/roles.guard.ts
Normal file
@ -0,0 +1,48 @@
|
||||
// roles.guard.ts
|
||||
import {
|
||||
CanActivate,
|
||||
ExecutionContext,
|
||||
Injectable,
|
||||
ForbiddenException,
|
||||
} from '@nestjs/common';
|
||||
import { Reflector } from '@nestjs/core';
|
||||
import { ROLES_KEY } from '../decorators/roles.decorator';
|
||||
import * as jwt from 'jsonwebtoken';
|
||||
import { UnauthorizedException } from 'src/exceptions/unauthorized.exception';
|
||||
|
||||
@Injectable()
|
||||
export class RolesGuard implements CanActivate {
|
||||
constructor(private reflector: Reflector) { }
|
||||
|
||||
canActivate(context: ExecutionContext): boolean {
|
||||
const requiredRoles = this.reflector.getAllAndOverride<string[]>(ROLES_KEY, [
|
||||
context.getHandler(),
|
||||
context.getClass(),
|
||||
]);
|
||||
if (!requiredRoles || requiredRoles.length === 0) return true;
|
||||
|
||||
const request = context.switchToHttp().getRequest();
|
||||
const token = request.cookies?.access_token; // Token is stored as HttpOnly cookie
|
||||
|
||||
if (!token) {
|
||||
throw new UnauthorizedException('Authentication Failed');
|
||||
}
|
||||
|
||||
try {
|
||||
const decoded: any = jwt.decode(token);
|
||||
|
||||
const roles: string[] = decoded?.resource_access?.['carnet-app']?.roles || [];
|
||||
const hasRole = requiredRoles.some(role => roles.includes(role));
|
||||
|
||||
if (!hasRole) {
|
||||
throw new ForbiddenException('Unauthorized : Please Request Access for this Resource');
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (err: any) {
|
||||
console.log("from roles guard : ", err.message);
|
||||
|
||||
throw new UnauthorizedException('Authentication Failed');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,19 +4,29 @@ import {
|
||||
NestInterceptor,
|
||||
ExecutionContext,
|
||||
CallHandler,
|
||||
BadRequestException,
|
||||
} from '@nestjs/common';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Observable, of } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class LogoutInterceptor implements NestInterceptor {
|
||||
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
|
||||
const request = context.switchToHttp().getRequest();
|
||||
const response = context.switchToHttp().getResponse();
|
||||
|
||||
const refreshToken = request.cookies?.refresh_token;
|
||||
|
||||
if (!refreshToken) {
|
||||
throw new BadRequestException('Refresh token not found in cookies');
|
||||
// Send a custom 200 response when refresh token is missing
|
||||
response.clearCookie('access_token');
|
||||
response.clearCookie('refresh_token');
|
||||
|
||||
response.status(200).json({
|
||||
statusCode: 200,
|
||||
message: 'Logged-Out successfully',
|
||||
});
|
||||
|
||||
// Prevent further handling
|
||||
return of(null);
|
||||
}
|
||||
|
||||
// Attach refresh token to request object for later use
|
||||
|
||||
@ -14,10 +14,11 @@ async function bootstrap() {
|
||||
logger: ['error', 'warn'],
|
||||
cors: {
|
||||
// origin: 'https://dev.alphaomegainfosys.com/',
|
||||
origin: '*',
|
||||
origin: ['http://localhost:3000', 'http://localhost:5173'],
|
||||
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
|
||||
preflightContinue: false,
|
||||
optionsSuccessStatus: 204,
|
||||
credentials: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Body, Controller, Patch, Post, Put } from '@nestjs/common';
|
||||
import { Body, Controller, Patch, Post, Put, UseGuards } from '@nestjs/common';
|
||||
import { CarnetApplicationService } from './carnet-application.service';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@ -12,9 +12,12 @@ import {
|
||||
UpdateShippingDetailsDTO
|
||||
} from 'src/dto/property.dto';
|
||||
import { Roles } from 'src/decorators/roles.decorator';
|
||||
import { JwtAuthGuard } from 'src/guards/jwt-auth.guard';
|
||||
import { RolesGuard } from 'src/guards/roles.guard';
|
||||
|
||||
|
||||
@ApiTags('Carnet Application - Oracle')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('ca', 'sa')
|
||||
@Controller('oracle')
|
||||
export class CarnetApplicationController {
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CarnetApplicationController } from './carnet-application.controller';
|
||||
import { CarnetApplicationService } from './carnet-application.service';
|
||||
import { AuthModule } from 'src/auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [AuthModule],
|
||||
controllers: [CarnetApplicationController],
|
||||
providers: [CarnetApplicationService]
|
||||
})
|
||||
|
||||
@ -2,6 +2,7 @@ import {
|
||||
Get,
|
||||
Param,
|
||||
Controller,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
|
||||
import { HomePageService } from './home-page.service';
|
||||
@ -13,8 +14,11 @@ import {
|
||||
USERID_DTO
|
||||
} from 'src/dto/property.dto';
|
||||
import { Roles } from 'src/decorators/roles.decorator';
|
||||
import { JwtAuthGuard } from 'src/guards/jwt-auth.guard';
|
||||
import { RolesGuard } from 'src/guards/roles.guard';
|
||||
|
||||
@ApiTags('HomePage - Oracle')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('ca', 'sa', 'ua')
|
||||
@Controller('oracle')
|
||||
export class HomePageController {
|
||||
|
||||
@ -2,9 +2,10 @@ import { Module } from '@nestjs/common';
|
||||
import { HomePageService } from './home-page.service';
|
||||
import { HomePageController } from './home-page.controller';
|
||||
import { DbModule } from 'src/db/db.module';
|
||||
import { AuthModule } from 'src/auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [DbModule],
|
||||
imports: [DbModule,AuthModule],
|
||||
providers: [HomePageService],
|
||||
controllers: [HomePageController],
|
||||
})
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Body, Controller, Get, Param, Patch, Post, Put, Query } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Param, Patch, Post, Put, Query, UseGuards } from '@nestjs/common';
|
||||
import { ManageClientsService } from './manage-clients.service';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@ -10,8 +10,11 @@ import {
|
||||
GetPreparersParamDTO, GetPreparersQueryDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO
|
||||
} from 'src/dto/property.dto';
|
||||
import { Roles } from 'src/decorators/roles.decorator';
|
||||
import { JwtAuthGuard } from 'src/guards/jwt-auth.guard';
|
||||
import { RolesGuard } from 'src/guards/roles.guard';
|
||||
|
||||
@ApiTags('Manage Clients - Oracle')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('sa')
|
||||
@Controller('oracle')
|
||||
export class ManageClientsController {
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ManageClientsController } from './manage-clients.controller';
|
||||
import { ManageClientsService } from './manage-clients.service';
|
||||
import { AuthModule } from 'src/auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [AuthModule],
|
||||
controllers: [ManageClientsController],
|
||||
providers: [ManageClientsService],
|
||||
})
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Body, Controller, Get, Param, Patch, Post, Query } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Param, Patch, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import { ManageFeeService } from './manage-fee.service';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@ -8,8 +8,11 @@ import {
|
||||
UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO
|
||||
} from 'src/dto/property.dto';
|
||||
import { Roles } from 'src/decorators/roles.decorator';
|
||||
import { JwtAuthGuard } from 'src/guards/jwt-auth.guard';
|
||||
import { RolesGuard } from 'src/guards/roles.guard';
|
||||
|
||||
@ApiTags('Manage Fee - Oracle')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('sa','ua')
|
||||
@Controller('oracle')
|
||||
export class ManageFeeController {
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ManageFeeController } from './manage-fee.controller';
|
||||
import { ManageFeeService } from './manage-fee.service';
|
||||
import { AuthModule } from 'src/auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [AuthModule],
|
||||
controllers: [ManageFeeController],
|
||||
providers: [ManageFeeService],
|
||||
})
|
||||
|
||||
@ -8,6 +8,7 @@ import {
|
||||
Patch,
|
||||
Post,
|
||||
Put,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { ManageHoldersService } from './manage-holders.service';
|
||||
@ -18,8 +19,11 @@ import {
|
||||
HolderContactActivateOrInactivateDTO, SearchHolderDTO, UpdateHolderContactDTO, UpdateHolderDTO
|
||||
} from 'src/dto/property.dto';
|
||||
import { Roles } from 'src/decorators/roles.decorator';
|
||||
import { JwtAuthGuard } from 'src/guards/jwt-auth.guard';
|
||||
import { RolesGuard } from 'src/guards/roles.guard';
|
||||
|
||||
@ApiTags('Manage Holders - Oracle')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('ca', 'sa')
|
||||
@Controller('oracle')
|
||||
export class ManageHoldersController {
|
||||
|
||||
@ -2,10 +2,11 @@ import { Module } from '@nestjs/common';
|
||||
import { ManageHoldersService } from './manage-holders.service';
|
||||
import { ManageHoldersController } from './manage-holders.controller';
|
||||
import { DbModule } from 'src/db/db.module';
|
||||
import { AuthModule } from 'src/auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [DbModule],
|
||||
imports: [DbModule, AuthModule],
|
||||
providers: [ManageHoldersService],
|
||||
controllers: [ManageHoldersController],
|
||||
controllers: [ManageHoldersController]
|
||||
})
|
||||
export class ManageHoldersModule {}
|
||||
export class ManageHoldersModule { }
|
||||
|
||||
@ -9,6 +9,7 @@ import { ManageClientsModule } from './manage-clients/manage-clients.module';
|
||||
import { UserMaintenanceModule } from './user-maintenance/user-maintenance.module';
|
||||
import { CarnetApplicationModule } from './carnet-application/carnet-application.module';
|
||||
import { OracleService } from './oracle.service';
|
||||
import { AuthModule } from 'src/auth/auth.module';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Body, Controller, Get, Patch, Post, Put, Query } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Patch, Post, Put, Query, UseGuards } from '@nestjs/common';
|
||||
import { ApiQuery, ApiTags } from '@nestjs/swagger';
|
||||
import { ParamTableService } from './param-table.service';
|
||||
|
||||
@ -7,6 +7,8 @@ import {
|
||||
getParamValuesDTO, UpdateParamRecordDTO
|
||||
} from 'src/dto/property.dto';
|
||||
import { Roles } from 'src/decorators/roles.decorator';
|
||||
import { JwtAuthGuard } from 'src/guards/jwt-auth.guard';
|
||||
import { RolesGuard } from 'src/guards/roles.guard';
|
||||
|
||||
@ApiTags('Param Table - Oracle')
|
||||
@Roles('sa', 'ua')
|
||||
@ -16,6 +18,7 @@ export class ParamTableController {
|
||||
|
||||
|
||||
@Get('/GetParamValues')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('ca', 'sa', 'ua')
|
||||
@ApiQuery({
|
||||
name: 'P_SPID',
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ParamTableController } from './param-table.controller';
|
||||
import { ParamTableService } from './param-table.service';
|
||||
import { AuthModule } from 'src/auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [AuthModule],
|
||||
controllers: [ParamTableController],
|
||||
providers: [ParamTableService],
|
||||
})
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Param, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { CarnetSequenceService } from './carnet-sequence.service';
|
||||
|
||||
import { SPID_DTO, CreateCarnetSequenceDTO } from 'src/dto/property.dto';
|
||||
import { Roles } from 'src/decorators/roles.decorator';
|
||||
import { JwtAuthGuard } from 'src/guards/jwt-auth.guard';
|
||||
import { RolesGuard } from 'src/guards/roles.guard';
|
||||
|
||||
@ApiTags('Carnet Sequence - Oracle')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('sa', 'ua')
|
||||
@Controller('oracle')
|
||||
export class CarnetSequenceController {
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { CarnetSequenceController } from './carnet-sequence.controller';
|
||||
import { CarnetSequenceService } from './carnet-sequence.service';
|
||||
import { AuthModule } from 'src/auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [AuthModule],
|
||||
controllers: [CarnetSequenceController],
|
||||
providers: [CarnetSequenceService],
|
||||
})
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
import { RegionService } from './region.service';
|
||||
|
||||
import { Get, Post, Body, Controller, Patch } from '@nestjs/common';
|
||||
import { Get, Post, Body, Controller, Patch, UseGuards } from '@nestjs/common';
|
||||
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { Roles } from 'src/decorators/roles.decorator';
|
||||
|
||||
import { InsertRegionsDto, UpdateRegionDto } from 'src/dto/property.dto';
|
||||
import { JwtAuthGuard } from 'src/guards/jwt-auth.guard';
|
||||
import { RolesGuard } from 'src/guards/roles.guard';
|
||||
|
||||
@ApiTags('Regions - Oracle')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('sa', 'ua')
|
||||
@Controller('oracle')
|
||||
export class RegionController {
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { RegionController } from './region.controller';
|
||||
import { RegionService } from './region.service';
|
||||
import { AuthModule } from 'src/auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [AuthModule],
|
||||
controllers: [RegionController],
|
||||
providers: [RegionService],
|
||||
})
|
||||
export class RegionModule {}
|
||||
export class RegionModule { }
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { SpContactsService } from './sp-contacts.service';
|
||||
import { Body, Controller, Get, Param, Patch, Post, Put, Query } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Param, Patch, Post, Put, Query, UseGuards } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { Roles } from 'src/decorators/roles.decorator';
|
||||
|
||||
@ -8,8 +8,11 @@ import {
|
||||
SP_CONTACTID_DTO,
|
||||
InsertSPContactsDTO, UpdateSPContactsDTO
|
||||
} from 'src/dto/property.dto';
|
||||
import { JwtAuthGuard } from 'src/guards/jwt-auth.guard';
|
||||
import { RolesGuard } from 'src/guards/roles.guard';
|
||||
|
||||
@ApiTags('SPContacts - Oracle')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('sa', 'ua')
|
||||
@Controller('oracle')
|
||||
export class SpContactsController {
|
||||
|
||||
@ -2,9 +2,10 @@ import { Module } from '@nestjs/common';
|
||||
import { SpContactsService } from './sp-contacts.service';
|
||||
import { SpContactsController } from './sp-contacts.controller';
|
||||
import { DbModule } from 'src/db/db.module';
|
||||
import { AuthModule } from 'src/auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [DbModule],
|
||||
imports: [DbModule,AuthModule],
|
||||
providers: [SpContactsService],
|
||||
controllers: [SpContactsController],
|
||||
})
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Body, Controller, Get, Param, Post, Put, Query } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Param, Post, Put, Query, UseGuards } from '@nestjs/common';
|
||||
import { SpService } from './sp.service';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@ -7,8 +7,11 @@ import {
|
||||
UpdateServiceProviderDTO,
|
||||
} from 'src/dto/property.dto';
|
||||
import { Roles } from 'src/decorators/roles.decorator';
|
||||
import { JwtAuthGuard } from 'src/guards/jwt-auth.guard';
|
||||
import { RolesGuard } from 'src/guards/roles.guard';
|
||||
|
||||
@ApiTags('SP - Oracle')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('sa', 'ua')
|
||||
@Controller('oracle')
|
||||
export class SpController {
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { SpController } from './sp.controller';
|
||||
import { SpService } from './sp.service';
|
||||
import { AuthModule } from 'src/auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [AuthModule],
|
||||
controllers: [SpController],
|
||||
providers: [SpService],
|
||||
})
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Body, Controller, Get, Param, Patch, Post, Query } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Param, Patch, Post, Query, UseGuards } from '@nestjs/common';
|
||||
import { UserMaintenanceService } from './user-maintenance.service';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@ -8,8 +8,11 @@ import {
|
||||
CreateClientLoginsDTO, CreateSPLoginsDTO, CreateUSCIBLoginsDTO, SPID_CLIENTID_DTO, SPID_EMAIL_DTO
|
||||
} from 'src/dto/property.dto';
|
||||
import { Roles } from 'src/decorators/roles.decorator';
|
||||
import { JwtAuthGuard } from 'src/guards/jwt-auth.guard';
|
||||
import { RolesGuard } from 'src/guards/roles.guard';
|
||||
|
||||
@ApiTags('User Maintenance - Oracle')
|
||||
@UseGuards(JwtAuthGuard, RolesGuard)
|
||||
@Roles('ca', 'sa', 'ua')
|
||||
@Controller('oracle')
|
||||
export class UserMaintenanceController {
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { UserMaintenanceController } from './user-maintenance.controller';
|
||||
import { UserMaintenanceService } from './user-maintenance.service';
|
||||
import { AuthModule } from 'src/auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [AuthModule],
|
||||
controllers: [UserMaintenanceController],
|
||||
providers: [UserMaintenanceService]
|
||||
})
|
||||
export class UserMaintenanceModule {}
|
||||
export class UserMaintenanceModule { }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user