From 4c88a72a2d800bb6c43490520ebd8d207cc78fbb Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Fri, 19 Dec 2025 08:53:19 -0500 Subject: [PATCH 1/8] feat(help): finish setup for help/home-page menu --- docs/swagger/swagger-spec.json | 14 ++++++++++++++ .../{home-page => help}/home-page.controller.ts | 2 +- .../{home-page => help}/home-page.module.ts | 4 ++-- .../{home-page => help}/home-page.service.ts | 2 +- .../identity-and-account.module.ts | 6 +++--- .../services/schedule-presets-apply.service.ts | 1 - 6 files changed, 21 insertions(+), 8 deletions(-) rename src/identity-and-account/{home-page => help}/home-page.controller.ts (87%) rename src/identity-and-account/{home-page => help}/home-page.module.ts (60%) rename src/identity-and-account/{home-page => help}/home-page.service.ts (98%) diff --git a/docs/swagger/swagger-spec.json b/docs/swagger/swagger-spec.json index 7bfacf3..7ad849b 100644 --- a/docs/swagger/swagger-spec.json +++ b/docs/swagger/swagger-spec.json @@ -300,6 +300,20 @@ ] } }, + "/schedule-presets/apply-day-preset": { + "post": { + "operationId": "SchedulePresetsController_applyPresetToDay", + "parameters": [], + "responses": { + "201": { + "description": "" + } + }, + "tags": [ + "SchedulePresets" + ] + } + }, "/expense/create": { "post": { "operationId": "ExpenseController_create", diff --git a/src/identity-and-account/home-page/home-page.controller.ts b/src/identity-and-account/help/home-page.controller.ts similarity index 87% rename from src/identity-and-account/home-page/home-page.controller.ts rename to src/identity-and-account/help/home-page.controller.ts index 870f501..50bbe5f 100644 --- a/src/identity-and-account/home-page/home-page.controller.ts +++ b/src/identity-and-account/help/home-page.controller.ts @@ -1,6 +1,6 @@ import { Controller, Get } from "@nestjs/common"; import { ModuleAccessAllowed } from "src/common/decorators/modules-guard.decorators"; -import { HomePageService } from "src/identity-and-account/home-page/home-page.service"; +import { HomePageService } from "src/identity-and-account/help/home-page.service"; import { Modules as ModulesEnum } from ".prisma/client"; import { Access } from "src/common/decorators/module-access.decorators"; diff --git a/src/identity-and-account/home-page/home-page.module.ts b/src/identity-and-account/help/home-page.module.ts similarity index 60% rename from src/identity-and-account/home-page/home-page.module.ts rename to src/identity-and-account/help/home-page.module.ts index 77c6ec8..03b0e98 100644 --- a/src/identity-and-account/home-page/home-page.module.ts +++ b/src/identity-and-account/help/home-page.module.ts @@ -1,7 +1,7 @@ import { Module } from "@nestjs/common"; import { EmailToIdResolver } from "src/common/mappers/email-id.mapper"; -import { HomePageController } from "src/identity-and-account/home-page/home-page.controller"; -import { HomePageService } from "src/identity-and-account/home-page/home-page.service"; +import { HomePageController } from "src/identity-and-account/help/home-page.controller"; +import { HomePageService } from "src/identity-and-account/help/home-page.service"; @Module({ controllers: [HomePageController], diff --git a/src/identity-and-account/home-page/home-page.service.ts b/src/identity-and-account/help/home-page.service.ts similarity index 98% rename from src/identity-and-account/home-page/home-page.service.ts rename to src/identity-and-account/help/home-page.service.ts index bd49cfb..acaa516 100644 --- a/src/identity-and-account/home-page/home-page.service.ts +++ b/src/identity-and-account/help/home-page.service.ts @@ -30,7 +30,7 @@ export class HomePageService { const help_message: string[] = []; if (module_access.dashboard) help_message.push('dashboard'); - if (module_access.personal_profile) help_message.push('personnal_profile'); + if (module_access.personal_profile) help_message.push('personal_profile'); if (module_access.timesheets) help_message.push('timesheets'); if (module_access.employee_list) help_message.push('employee_list'); if (module_access.employee_management) help_message.push('employee_management'); diff --git a/src/identity-and-account/identity-and-account.module.ts b/src/identity-and-account/identity-and-account.module.ts index 90c6601..8031a91 100644 --- a/src/identity-and-account/identity-and-account.module.ts +++ b/src/identity-and-account/identity-and-account.module.ts @@ -12,11 +12,11 @@ import { AccessGetService } from "src/identity-and-account/user-module-access/se import { AccessUpdateService } from "src/identity-and-account/user-module-access/services/module-access-update.service"; import { UsersService } from "src/identity-and-account/users-management/services/users.service"; import { UsersModule } from "src/identity-and-account/users-management/users.module"; -import { HomePageModule } from "src/identity-and-account/home-page/home-page.module"; +import { HomePageModule } from "src/identity-and-account/help/home-page.module"; import { EmployeesCreateService } from "src/identity-and-account/employees/services/employees-create.service"; import { EmployeesUpdateService } from "src/identity-and-account/employees/services/employees-update.service"; -import { HomePageController } from "src/identity-and-account/home-page/home-page.controller"; -import { HomePageService } from "src/identity-and-account/home-page/home-page.service"; +import { HomePageController } from "src/identity-and-account/help/home-page.controller"; +import { HomePageService } from "src/identity-and-account/help/home-page.service"; @Module({ imports: [ diff --git a/src/time-and-attendance/schedule-presets/services/schedule-presets-apply.service.ts b/src/time-and-attendance/schedule-presets/services/schedule-presets-apply.service.ts index ed471c4..8d2de21 100644 --- a/src/time-and-attendance/schedule-presets/services/schedule-presets-apply.service.ts +++ b/src/time-and-attendance/schedule-presets/services/schedule-presets-apply.service.ts @@ -115,7 +115,6 @@ export class SchedulePresetsApplyService { await this.createShiftFromPreset(shift, toDateFromString(date), timesheet_id); } - // await this.shiftService.createShift(employee_id.data, shift); return { success: true, data: true }; } From a80dd357a357b7c502b74b856517a53782d148bb Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Fri, 19 Dec 2025 09:24:26 -0500 Subject: [PATCH 2/8] feat(debugging): temporary guard disable and comment for troubleshooting dockerization of the staging app. to be rolled-back before prod --- .../controllers/auth.controller.ts | 4 ++-- .../guards/authentik-auth.guard.ts | 1 + .../strategies/authentik.strategy.ts | 1 + src/main.ts | 21 +++++++++++++------ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/identity-and-account/authentication/controllers/auth.controller.ts b/src/identity-and-account/authentication/controllers/auth.controller.ts index 43c9397..d0d8b06 100644 --- a/src/identity-and-account/authentication/controllers/auth.controller.ts +++ b/src/identity-and-account/authentication/controllers/auth.controller.ts @@ -5,12 +5,12 @@ import { Request, Response } from 'express'; @Controller('auth') export class AuthController { - @UseGuards(OIDCLoginGuard) + // @UseGuards(OIDCLoginGuard) @Get('/v1/login') login() { } @Get('/callback') - @UseGuards(OIDCLoginGuard) + // @UseGuards(OIDCLoginGuard) loginCallback(@Req() req: Request, @Res() res: Response) { // res.redirect('http://10.100.251.2:9011/#/login-success'); res.redirect('http://localhost:9000/#/login-success'); diff --git a/src/identity-and-account/authentication/guards/authentik-auth.guard.ts b/src/identity-and-account/authentication/guards/authentik-auth.guard.ts index ff4f44d..1fb423a 100644 --- a/src/identity-and-account/authentication/guards/authentik-auth.guard.ts +++ b/src/identity-and-account/authentication/guards/authentik-auth.guard.ts @@ -6,6 +6,7 @@ export class OIDCLoginGuard extends AuthGuard('openidconnect') { async canActivate(context: ExecutionContext) { const result = (await super.canActivate(context)) as boolean; const request = context.switchToHttp().getRequest(); + console.log('JWT HEADER:', request.headers.authorization); await super.logIn(request); return result; } diff --git a/src/identity-and-account/authentication/strategies/authentik.strategy.ts b/src/identity-and-account/authentication/strategies/authentik.strategy.ts index 5d1c029..4bfd32d 100644 --- a/src/identity-and-account/authentication/strategies/authentik.strategy.ts +++ b/src/identity-and-account/authentication/strategies/authentik.strategy.ts @@ -53,6 +53,7 @@ export class AuthentikStrategy extends PassportStrategy(OIDCStrategy, 'openidcon const components = _idToken.split('.'); const payload = Buffer.from(components[1], "base64").toString('utf-8'); + console.log('JWT PAYLOAD:', payload); const claims = JSON.parse(payload); if (!claims.email) return cb(new Error('Missing email in OIDC profile'), false); diff --git a/src/main.ts b/src/main.ts index d4b520d..d8d1f1b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,6 +16,7 @@ import * as session from 'express-session'; import * as passport from 'passport'; import { PrismaService } from 'src/prisma/prisma.service'; import { PrismaSessionStore } from '@quixo3/prisma-session-store'; + // import { extractOldShifts } from 'scripts/migrate-shifts'; // import { extractOldTimesheets } from 'scripts/migrate-timesheets'; // import { extractOldExpenses } from 'scripts/migrate-expenses'; @@ -23,11 +24,24 @@ import { PrismaSessionStore } from '@quixo3/prisma-session-store'; const SESSION_TOKEN_DURATION_MINUTES = 180 async function bootstrap() { + const app = await NestFactory.create(AppModule); const prisma_service = app.get(PrismaService); - const reflector = app.get(Reflector); + app.use((req, res, next) => { + console.log('--- INCOMING REQUEST ---'); + console.log('METHOD:', req.method); + console.log('URL:', req.originalUrl); + console.log('HEADERS:', req.headers); + console.log('BODY:', req.body); + console.log('------------------------'); + console.log(req.headers.authorization); + console.log(req.headers['x-authentik-signature']); + console.log(req.headers['content-type)']); + next(); + }); + app.useGlobalGuards( // new JwtAuthGuard(reflector), //Authentification JWT new ModulesGuard(reflector), //deny-by-default and Module-based Access Control @@ -89,11 +103,6 @@ async function bootstrap() { SwaggerModule.setup('api/docs', app, document); writeFileSync('./docs/swagger/swagger-spec.json', JSON.stringify(document, null, 2)); - // logs to be removed post dev - console.log('[ENV.ATTACHMENTS_ROOT]', process.env.ATTACHMENTS_ROOT); - console.log('[resolveAttachmentsRoot()]', resolveAttachmentsRoot()); - console.log('[ATT_TMP_DIR()]', ATT_TMP_DIR()); - await ensureAttachmentsTmpDir(); await app.listen(process.env.PORT ?? 3000); From 3a0dc4c1ce58cab27c685bc3d553f962c8eef9a8 Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Fri, 19 Dec 2025 09:54:51 -0500 Subject: [PATCH 3/8] feat(troubleshooting): roll-back du dernier commit et clean de debugg comments --- .../controllers/auth.controller.ts | 4 +- .../guards/authentik-auth.guard.ts | 1 - .../strategies/authentik.strategy.ts | 1 - src/main.ts | 78 ++++++++----------- 4 files changed, 33 insertions(+), 51 deletions(-) diff --git a/src/identity-and-account/authentication/controllers/auth.controller.ts b/src/identity-and-account/authentication/controllers/auth.controller.ts index d0d8b06..43c9397 100644 --- a/src/identity-and-account/authentication/controllers/auth.controller.ts +++ b/src/identity-and-account/authentication/controllers/auth.controller.ts @@ -5,12 +5,12 @@ import { Request, Response } from 'express'; @Controller('auth') export class AuthController { - // @UseGuards(OIDCLoginGuard) + @UseGuards(OIDCLoginGuard) @Get('/v1/login') login() { } @Get('/callback') - // @UseGuards(OIDCLoginGuard) + @UseGuards(OIDCLoginGuard) loginCallback(@Req() req: Request, @Res() res: Response) { // res.redirect('http://10.100.251.2:9011/#/login-success'); res.redirect('http://localhost:9000/#/login-success'); diff --git a/src/identity-and-account/authentication/guards/authentik-auth.guard.ts b/src/identity-and-account/authentication/guards/authentik-auth.guard.ts index 1fb423a..ff4f44d 100644 --- a/src/identity-and-account/authentication/guards/authentik-auth.guard.ts +++ b/src/identity-and-account/authentication/guards/authentik-auth.guard.ts @@ -6,7 +6,6 @@ export class OIDCLoginGuard extends AuthGuard('openidconnect') { async canActivate(context: ExecutionContext) { const result = (await super.canActivate(context)) as boolean; const request = context.switchToHttp().getRequest(); - console.log('JWT HEADER:', request.headers.authorization); await super.logIn(request); return result; } diff --git a/src/identity-and-account/authentication/strategies/authentik.strategy.ts b/src/identity-and-account/authentication/strategies/authentik.strategy.ts index 4bfd32d..5d1c029 100644 --- a/src/identity-and-account/authentication/strategies/authentik.strategy.ts +++ b/src/identity-and-account/authentication/strategies/authentik.strategy.ts @@ -53,7 +53,6 @@ export class AuthentikStrategy extends PassportStrategy(OIDCStrategy, 'openidcon const components = _idToken.split('.'); const payload = Buffer.from(components[1], "base64").toString('utf-8'); - console.log('JWT PAYLOAD:', payload); const claims = JSON.parse(payload); if (!claims.email) return cb(new Error('Missing email in OIDC profile'), false); diff --git a/src/main.ts b/src/main.ts index d8d1f1b..c847ba5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,19 +4,16 @@ if (!(globalThis as any).crypto) { (globalThis as any).crypto = nodeCrypto; } import { ensureAttachmentsTmpDir } from './time-and-attendance/attachments/config/attachment.fs'; -import { resolveAttachmentsRoot } from './time-and-attendance/attachments/config/attachment.config';// log to be removed post dev -import { ATT_TMP_DIR } from './time-and-attendance/attachments/config/attachment.config'; // log to be removed post dev import { NestFactory, Reflector } from '@nestjs/core'; import { AppModule } from './app.module'; // import { JwtAuthGuard } from './modules/authentication/guards/jwt-auth.guard'; import { ModulesGuard } from './common/guards/modules.guard'; -import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; -import { writeFileSync } from 'fs'; +// import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; +// import { writeFileSync } from 'fs'; import * as session from 'express-session'; import * as passport from 'passport'; import { PrismaService } from 'src/prisma/prisma.service'; import { PrismaSessionStore } from '@quixo3/prisma-session-store'; - // import { extractOldShifts } from 'scripts/migrate-shifts'; // import { extractOldTimesheets } from 'scripts/migrate-timesheets'; // import { extractOldExpenses } from 'scripts/migrate-expenses'; @@ -24,23 +21,10 @@ import { PrismaSessionStore } from '@quixo3/prisma-session-store'; const SESSION_TOKEN_DURATION_MINUTES = 180 async function bootstrap() { - const app = await NestFactory.create(AppModule); const prisma_service = app.get(PrismaService); - const reflector = app.get(Reflector); - app.use((req, res, next) => { - console.log('--- INCOMING REQUEST ---'); - console.log('METHOD:', req.method); - console.log('URL:', req.originalUrl); - console.log('HEADERS:', req.headers); - console.log('BODY:', req.body); - console.log('------------------------'); - console.log(req.headers.authorization); - console.log(req.headers['x-authentik-signature']); - console.log(req.headers['content-type)']); - next(); - }); + const reflector = app.get(Reflector); app.useGlobalGuards( // new JwtAuthGuard(reflector), //Authentification JWT @@ -73,35 +57,35 @@ async function bootstrap() { credentials: true, }); - //swagger config - const config = new DocumentBuilder() - .setTitle('Targo_Backend') - .setDescription('Documentation de l`API REST pour Targo (NestJS + Prisma)') - .setVersion('1.0') - .addBearerAuth({ - type: 'http', - scheme: 'bearer', - bearerFormat: 'JWT', - name: 'Authorization', - description: 'Invalid JWT token', - in: 'header', - }, 'access-token') - .addTag('Users') - .addTag('Employees') - .addTag('Customers') - .addTag('Timesheets') - .addTag('Shifts') - .addTag('Leave Requests') - .addTag('Shift Codes') - .addTag('OAuth Access Tokens') - .addTag('Authorization') - .build(); + // //swagger config + // const config = new DocumentBuilder() + // .setTitle('Targo_Backend') + // .setDescription('Documentation de l`API REST pour Targo (NestJS + Prisma)') + // .setVersion('1.0') + // .addBearerAuth({ + // type: 'http', + // scheme: 'bearer', + // bearerFormat: 'JWT', + // name: 'Authorization', + // description: 'Invalid JWT token', + // in: 'header', + // }, 'access-token') + // .addTag('Users') + // .addTag('Employees') + // .addTag('Customers') + // .addTag('Timesheets') + // .addTag('Shifts') + // .addTag('Leave Requests') + // .addTag('Shift Codes') + // .addTag('OAuth Access Tokens') + // .addTag('Authorization') + // .build(); - //document builder for swagger docs - const documentFactory = () => SwaggerModule.createDocument(app, config); - const document = documentFactory() - SwaggerModule.setup('api/docs', app, document); - writeFileSync('./docs/swagger/swagger-spec.json', JSON.stringify(document, null, 2)); + // //document builder for swagger docs + // const documentFactory = () => SwaggerModule.createDocument(app, config); + // const document = documentFactory() + // SwaggerModule.setup('api/docs', app, document); + // writeFileSync('./docs/swagger/swagger-spec.json', JSON.stringify(document, null, 2)); await ensureAttachmentsTmpDir(); await app.listen(process.env.PORT ?? 3000); From 62bad94343670540dff2d4e3cfb69c65dddb7c3d Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Fri, 19 Dec 2025 10:00:50 -0500 Subject: [PATCH 4/8] feat(redirect_url): moved redirect url to .env file --- .../authentication/controllers/auth.controller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/identity-and-account/authentication/controllers/auth.controller.ts b/src/identity-and-account/authentication/controllers/auth.controller.ts index 43c9397..0b09814 100644 --- a/src/identity-and-account/authentication/controllers/auth.controller.ts +++ b/src/identity-and-account/authentication/controllers/auth.controller.ts @@ -12,8 +12,8 @@ export class AuthController { @Get('/callback') @UseGuards(OIDCLoginGuard) loginCallback(@Req() req: Request, @Res() res: Response) { - // res.redirect('http://10.100.251.2:9011/#/login-success'); - res.redirect('http://localhost:9000/#/login-success'); + res.redirect('REDIRECT_URL_STAGING'); + // res.redirect('REDIRECT_URL_DEV'); } @Get('/me') From a40af6a4d0c31f780287e2964ea2e584abb73e04 Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Fri, 19 Dec 2025 10:11:29 -0500 Subject: [PATCH 5/8] fix():small fix to redirect --- .../authentication/controllers/auth.controller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/identity-and-account/authentication/controllers/auth.controller.ts b/src/identity-and-account/authentication/controllers/auth.controller.ts index 0b09814..3259f65 100644 --- a/src/identity-and-account/authentication/controllers/auth.controller.ts +++ b/src/identity-and-account/authentication/controllers/auth.controller.ts @@ -12,8 +12,8 @@ export class AuthController { @Get('/callback') @UseGuards(OIDCLoginGuard) loginCallback(@Req() req: Request, @Res() res: Response) { - res.redirect('REDIRECT_URL_STAGING'); - // res.redirect('REDIRECT_URL_DEV'); + res.redirect('process.env.REDIRECT_URL_STAGING'); + // res.redirect('process.env.REDIRECT_URL_DEV'); } @Get('/me') From 40fe965a6ddbcc00e289c8890932a49d5f9cca3d Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Fri, 19 Dec 2025 10:16:30 -0500 Subject: [PATCH 6/8] fix(redirect): fix url redirect --- .../authentication/controllers/auth.controller.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/identity-and-account/authentication/controllers/auth.controller.ts b/src/identity-and-account/authentication/controllers/auth.controller.ts index 3259f65..33ff1f0 100644 --- a/src/identity-and-account/authentication/controllers/auth.controller.ts +++ b/src/identity-and-account/authentication/controllers/auth.controller.ts @@ -1,6 +1,7 @@ import { Controller, Get, Req, Res, UnauthorizedException, UseGuards } from '@nestjs/common'; import { OIDCLoginGuard } from '../guards/authentik-auth.guard'; import { Request, Response } from 'express'; +import { env } from 'node:process'; @Controller('auth') export class AuthController { @@ -12,8 +13,8 @@ export class AuthController { @Get('/callback') @UseGuards(OIDCLoginGuard) loginCallback(@Req() req: Request, @Res() res: Response) { - res.redirect('process.env.REDIRECT_URL_STAGING'); - // res.redirect('process.env.REDIRECT_URL_DEV'); + res.redirect(process.env.REDIRECT_URL_STAGING!); + // res.redirect(process.env.REDIRECT_URL_DEV!); } @Get('/me') From 027dd48efb9b9b08d4caf505bbe43f8567249b31 Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Fri, 19 Dec 2025 12:23:55 -0500 Subject: [PATCH 7/8] fix(module-access): fix module access for none-admin users --- .../controllers/auth.controller.ts | 1 - .../employees/employees.controller.ts | 2 +- .../schedule-presets.controller.ts | 2 +- .../schedule-presets/schedule-presets.dto.ts | 1 - .../services/schedule-presets-apply.service.ts | 2 -- .../services/schedule-presets-create.service.ts | 14 +++++++------- .../services/schedule-presets-delete.service.ts | 17 +++++++++++------ .../services/schedule-presets-get.service.ts | 3 +-- .../services/schedule-presets-update.service.ts | 11 ----------- .../timesheets/timesheet.controller.ts | 2 +- 10 files changed, 22 insertions(+), 33 deletions(-) diff --git a/src/identity-and-account/authentication/controllers/auth.controller.ts b/src/identity-and-account/authentication/controllers/auth.controller.ts index 33ff1f0..2c3c666 100644 --- a/src/identity-and-account/authentication/controllers/auth.controller.ts +++ b/src/identity-and-account/authentication/controllers/auth.controller.ts @@ -1,7 +1,6 @@ import { Controller, Get, Req, Res, UnauthorizedException, UseGuards } from '@nestjs/common'; import { OIDCLoginGuard } from '../guards/authentik-auth.guard'; import { Request, Response } from 'express'; -import { env } from 'node:process'; @Controller('auth') export class AuthController { diff --git a/src/identity-and-account/employees/employees.controller.ts b/src/identity-and-account/employees/employees.controller.ts index e3eed2e..7b68d6d 100644 --- a/src/identity-and-account/employees/employees.controller.ts +++ b/src/identity-and-account/employees/employees.controller.ts @@ -23,7 +23,7 @@ export class EmployeesController { } @Get('profile') - @ModuleAccessAllowed(ModulesEnum.employee_management) + @ModuleAccessAllowed(ModulesEnum.personal_profile) async findProfile(@Access('email') email: string, @Query('employee_email') employee_email?: string, ): Promise, string>> { return await this.getService.findOneDetailedProfile(email, employee_email); diff --git a/src/time-and-attendance/schedule-presets/schedule-presets.controller.ts b/src/time-and-attendance/schedule-presets/schedule-presets.controller.ts index 7293438..7da9c20 100644 --- a/src/time-and-attendance/schedule-presets/schedule-presets.controller.ts +++ b/src/time-and-attendance/schedule-presets/schedule-presets.controller.ts @@ -43,7 +43,7 @@ export class SchedulePresetsController { @Delete('delete/:id') @ModuleAccessAllowed(ModulesEnum.employee_management) async deletePreset( - @Param('id', ParseIntPipe) id: number) { + @Param('id') id: number) { return await this.deleteService.deletePreset(id); } diff --git a/src/time-and-attendance/schedule-presets/schedule-presets.dto.ts b/src/time-and-attendance/schedule-presets/schedule-presets.dto.ts index 13edcbc..0f36838 100644 --- a/src/time-and-attendance/schedule-presets/schedule-presets.dto.ts +++ b/src/time-and-attendance/schedule-presets/schedule-presets.dto.ts @@ -5,7 +5,6 @@ import { HH_MM_REGEX } from "src/common/utils/constants.utils"; export class SchedulePresetsDto { @IsInt() id!: number; @IsString() name!: string; - @IsBoolean() @IsOptional() is_default: boolean; @IsArray() @ArrayMinSize(1) shifts: SchedulePresetShiftsDto[]; } diff --git a/src/time-and-attendance/schedule-presets/services/schedule-presets-apply.service.ts b/src/time-and-attendance/schedule-presets/services/schedule-presets-apply.service.ts index 27bb1fe..668418a 100644 --- a/src/time-and-attendance/schedule-presets/services/schedule-presets-apply.service.ts +++ b/src/time-and-attendance/schedule-presets/services/schedule-presets-apply.service.ts @@ -32,7 +32,6 @@ export class SchedulePresetsApplyService { schedule_preset: { select: { id: true, - is_default: true, shifts: true, }, }, @@ -94,7 +93,6 @@ export class SchedulePresetsApplyService { schedule_preset: { select: { id: true, - is_default: true, shifts: { where: { week_day: $Enums.Weekday[week_day] }, select: { diff --git a/src/time-and-attendance/schedule-presets/services/schedule-presets-create.service.ts b/src/time-and-attendance/schedule-presets/services/schedule-presets-create.service.ts index f152856..06be417 100644 --- a/src/time-and-attendance/schedule-presets/services/schedule-presets-create.service.ts +++ b/src/time-and-attendance/schedule-presets/services/schedule-presets-create.service.ts @@ -56,17 +56,17 @@ export class SchedulePresetsCreateService { await this.prisma.$transaction(async (tx) => { //check if employee chose this preset has a default preset and ensure all others are false - if (dto.is_default) { - await tx.schedulePresets.updateMany({ - where: { is_default: true }, - data: { is_default: false }, - }); - } + // if (dto.is_default) { + // await tx.schedulePresets.updateMany({ + // where: { is_default: true }, + // data: { is_default: false }, + // }); + // } await tx.schedulePresets.create({ data: { name: dto.name, - is_default: dto.is_default ?? false, + // is_default: dto.is_default ?? false, shifts: { create: dto.shifts.map((shift, index) => { //validated bank_codes sent as a Result Array to access its data diff --git a/src/time-and-attendance/schedule-presets/services/schedule-presets-delete.service.ts b/src/time-and-attendance/schedule-presets/services/schedule-presets-delete.service.ts index 4496dcd..62730c1 100644 --- a/src/time-and-attendance/schedule-presets/services/schedule-presets-delete.service.ts +++ b/src/time-and-attendance/schedule-presets/services/schedule-presets-delete.service.ts @@ -1,6 +1,8 @@ +import { Injectable } from "@nestjs/common"; import { Result } from "src/common/errors/result-error.factory"; import { PrismaService } from "src/prisma/prisma.service"; +@Injectable() export class SchedulePresetDeleteService { constructor(private readonly prisma: PrismaService) { } @@ -8,19 +10,22 @@ export class SchedulePresetDeleteService { // DELETE //_________________________________________________________________ async deletePreset(preset_id: number): Promise> { - const preset = await this.prisma.schedulePresets.findFirst({ + console.log('preset_id received: ', preset_id) + + const preset = await this.prisma.schedulePresets.findUnique({ where: { id: preset_id }, select: { id: true }, }); if (!preset) return { success: false, error: `SCHEDULE_PRESET_NOT_FOUND` }; - - await this.prisma.employees.updateMany({ - where: { schedule_preset_id: preset.id }, + console.log('preset found: ', preset.id) + + const updated_employees = await this.prisma.employees.updateMany({ + where: { schedule_preset_id: preset_id }, data: { - schedule_preset_id: null, + schedule_preset_id: 0, }, - }); + console.log('employee schedule id updated', updated_employees); await this.prisma.$transaction(async (tx) => { await tx.schedulePresetShifts.deleteMany({ where: { preset_id: preset_id } }); diff --git a/src/time-and-attendance/schedule-presets/services/schedule-presets-get.service.ts b/src/time-and-attendance/schedule-presets/services/schedule-presets-get.service.ts index ed641a4..af8efe9 100644 --- a/src/time-and-attendance/schedule-presets/services/schedule-presets-get.service.ts +++ b/src/time-and-attendance/schedule-presets/services/schedule-presets-get.service.ts @@ -15,7 +15,7 @@ export class SchedulePresetsGetService { async getSchedulePresets(): Promise> { try { const presets = await this.prisma.schedulePresets.findMany({ - orderBy: [{ is_default: 'desc' }, { name: 'asc' }], + orderBy: [{ name: 'asc' }], include: { shifts: { orderBy: [{ week_day: 'asc' }, { start_time: 'asc' }], @@ -28,7 +28,6 @@ export class SchedulePresetsGetService { const response: SchedulePresetsDto[] = presets.map((preset) => ({ id: preset.id, name: preset.name, - is_default: preset.is_default, shifts: preset.shifts.map>((shift) => ({ preset_id: shift.preset_id, week_day: shift.week_day, diff --git a/src/time-and-attendance/schedule-presets/services/schedule-presets-update.service.ts b/src/time-and-attendance/schedule-presets/services/schedule-presets-update.service.ts index 3b6a9b7..57998c5 100644 --- a/src/time-and-attendance/schedule-presets/services/schedule-presets-update.service.ts +++ b/src/time-and-attendance/schedule-presets/services/schedule-presets-update.service.ts @@ -22,7 +22,6 @@ export class SchedulePresetUpdateService { where: { id: dto.id }, select: { id: true, - is_default: true, shifts: true, }, }); @@ -52,22 +51,12 @@ export class SchedulePresetUpdateService { } await this.prisma.$transaction(async (tx) => { - if (dto.is_default) { - await tx.schedulePresets.updateMany({ - where: { - is_default: true, - NOT: { id: existing.id }, - }, - data: { is_default: false }, - }); - } await tx.schedulePresetShifts.deleteMany({ where: { preset_id: existing.id } }); await tx.schedulePresets.update({ where: { id: existing.id }, data: { name: dto.name, - is_default: dto.is_default ?? false, shifts: { create: dto.shifts.map((shift, index) => { const result = bank_code_results[index] as { success: true, data: number }; diff --git a/src/time-and-attendance/timesheets/timesheet.controller.ts b/src/time-and-attendance/timesheets/timesheet.controller.ts index eb5050a..448f459 100644 --- a/src/time-and-attendance/timesheets/timesheet.controller.ts +++ b/src/time-and-attendance/timesheets/timesheet.controller.ts @@ -14,7 +14,7 @@ export class TimesheetController { ) { } @Get(':year/:period_number') - @ModuleAccessAllowed(ModulesEnum.timesheets_approval) + @ModuleAccessAllowed(ModulesEnum.timesheets) getTimesheetByPayPeriod( @Access('email') email: string, @Param('year', ParseIntPipe) year: number, From 681779345e0019a55f5df5871caee64bd99b09e0 Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Fri, 19 Dec 2025 12:43:11 -0500 Subject: [PATCH 8/8] fix(access): access troubleshooting --- .../authentication/controllers/auth.controller.ts | 2 +- src/time-and-attendance/bank-codes/bank-codes.controller.ts | 3 --- .../pay-period/pay-periods.controller.ts | 6 +++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/identity-and-account/authentication/controllers/auth.controller.ts b/src/identity-and-account/authentication/controllers/auth.controller.ts index 2c3c666..ce925fb 100644 --- a/src/identity-and-account/authentication/controllers/auth.controller.ts +++ b/src/identity-and-account/authentication/controllers/auth.controller.ts @@ -12,7 +12,7 @@ export class AuthController { @Get('/callback') @UseGuards(OIDCLoginGuard) loginCallback(@Req() req: Request, @Res() res: Response) { - res.redirect(process.env.REDIRECT_URL_STAGING!); + res.redirect("http://10.100.251.2:9013/#/v1/login-success"); // res.redirect(process.env.REDIRECT_URL_DEV!); } diff --git a/src/time-and-attendance/bank-codes/bank-codes.controller.ts b/src/time-and-attendance/bank-codes/bank-codes.controller.ts index 23048a8..550847c 100644 --- a/src/time-and-attendance/bank-codes/bank-codes.controller.ts +++ b/src/time-and-attendance/bank-codes/bank-codes.controller.ts @@ -13,20 +13,17 @@ export class BankCodesControllers { //_____________________________________________________________________________________________ @Post() - @ModuleAccessAllowed(ModulesEnum.employee_management) create(@Body() dto: Prisma.BankCodesCreateInput ): Promise> { return this.bankCodesService.create(dto); } @Get() - @ModuleAccessAllowed(ModulesEnum.employee_management) findAll() { return this.bankCodesService.findAll(); } @Patch(':id') - @ModuleAccessAllowed(ModulesEnum.employee_management) update(@Param('id', ParseIntPipe) id: number, @Body() dto: Prisma.BankCodesUpdateInput ): Promise> { return this.bankCodesService.update(id, dto) diff --git a/src/time-and-attendance/pay-period/pay-periods.controller.ts b/src/time-and-attendance/pay-period/pay-periods.controller.ts index e900cae..52ba773 100644 --- a/src/time-and-attendance/pay-period/pay-periods.controller.ts +++ b/src/time-and-attendance/pay-period/pay-periods.controller.ts @@ -17,7 +17,7 @@ export class PayPeriodsController { ) { } @Get('current-and-all') - @ModuleAccessAllowed(ModulesEnum.timesheets_approval) + @ModuleAccessAllowed(ModulesEnum.timesheets) async getCurrentAndAll(@Query('date') date?: string): Promise> { const current = await this.queryService.findCurrent(date); if (!current.success) return { success: false, error: 'INVALID_PAY_PERIOD' }; @@ -29,13 +29,13 @@ export class PayPeriodsController { } @Get("date/:date") - @ModuleAccessAllowed(ModulesEnum.timesheets_approval) + @ModuleAccessAllowed(ModulesEnum.timesheets) async findByDate(@Param("date") date: string) { return this.queryService.findByDate(date); } @Get(":year/:periodNumber") - @ModuleAccessAllowed(ModulesEnum.timesheets_approval) + @ModuleAccessAllowed(ModulesEnum.timesheets) async findOneByYear( @Param("year", ParseIntPipe) year: number, @Param("periodNumber", ParseIntPipe) period_no: number,