diff --git a/src/app.module.ts b/src/app.module.ts index 91f6af6..ae2e569 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -6,7 +6,6 @@ import { AuthenticationModule } from './identity-and-account/authentication/auth import { HealthModule } from './health/health.module'; import { HealthController } from './health/health.controller'; import { NotificationsModule } from './modules/notifications/notifications.module'; -import { OauthSessionsModule } from './identity-and-account/oauth-sessions/oauth-sessions.module'; import { PreferencesModule } from './identity-and-account/preferences/preferences.module'; import { PrismaModule } from './prisma/prisma.module'; import { ScheduleModule } from '@nestjs/schedule'; @@ -25,7 +24,6 @@ import { TimeAndAttendanceModule } from 'src/time-and-attendance/time-and-attend // CsvExportModule, HealthModule, NotificationsModule, - OauthSessionsModule, PayperiodsModule, PreferencesModule, PrismaModule, diff --git a/src/identity-and-account/oauth-sessions/controllers/oauth-sessions.controller.ts b/src/identity-and-account/oauth-sessions/controllers/oauth-sessions.controller.ts deleted file mode 100644 index 2e5b54c..0000000 --- a/src/identity-and-account/oauth-sessions/controllers/oauth-sessions.controller.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Body, Controller, Delete, Get, Param, Patch, Post, UseGuards } from '@nestjs/common'; -import { OAuthSessions } from '@prisma/client'; -import { RolesAllowed } from "src/common/decorators/roles.decorators"; -import { Roles as RoleEnum } from '.prisma/client'; -import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; -import { CreateOauthSessionDto } from '../dtos/create-oauth-session.dto'; -import { OauthSessionsService } from '../services/oauth-sessions.service'; -import { UpdateOauthSessionDto } from '../dtos/update-oauth-session.dto'; - -@ApiTags('OAuth Sessions') -@ApiBearerAuth('sessions') -//@UseGuards(JwtAuthGuard) -@Controller('oauth-sessions') -export class OauthSessionsController { - constructor(private readonly oauthSessionsService: OauthSessionsService){} - - @Post() - // @RolesAllowed(RoleEnum.ADMIN) - @ApiOperation({summary: 'Create OAuth session' }) - @ApiResponse({ status: 201, description: 'OAuth session created', type: CreateOauthSessionDto }) - @ApiResponse({ status: 400, description: 'Incomplete task or invalid data' }) - create(@Body()dto: CreateOauthSessionDto): Promise { - return this.oauthSessionsService.create(dto); - } - - @Get() - //@RolesAllowed(RoleEnum.ADMIN) - @ApiOperation({summary: 'Find all OAuth session' }) - @ApiResponse({ status: 201, description: 'List of OAuth session found', type: CreateOauthSessionDto, isArray: true }) - @ApiResponse({ status: 400, description: 'List of OAuth session not found' }) - findAll(): Promise { - return this.oauthSessionsService.findAll(); - } - - @Get(':id') - //@RolesAllowed(RoleEnum.ADMIN) - @ApiOperation({summary: 'Find OAuth session' }) - @ApiResponse({ status: 201, description: 'OAuth session found', type: CreateOauthSessionDto }) - @ApiResponse({ status: 400, description: 'OAuth session not found' }) - findOne(@Param('id') id: string): Promise { - return this.oauthSessionsService.findOne(id); - } - - @Patch(':id') - //@RolesAllowed(RoleEnum.ADMIN) - @ApiOperation({summary: 'Update OAuth session' }) - @ApiResponse({ status: 201, description: 'OAuth session updated', type: CreateOauthSessionDto }) - @ApiResponse({ status: 400, description: 'OAuth session not found' }) - update(@Param('id') id: string, @Body() dto: UpdateOauthSessionDto): Promise { - return this.oauthSessionsService.update(id,dto); - } - - @Delete(':id') - //@RolesAllowed(RoleEnum.ADMIN) - @ApiOperation({summary: 'Delete OAuth session' }) - @ApiResponse({ status: 201, description: 'OAuth session deleted', type: CreateOauthSessionDto }) - @ApiResponse({ status: 400, description: 'OAuth session not found' }) - remove(@Param('id') id: string): Promise { - return this.oauthSessionsService.remove(id); - } -} diff --git a/src/identity-and-account/oauth-sessions/dtos/create-oauth-session.dto.ts b/src/identity-and-account/oauth-sessions/dtos/create-oauth-session.dto.ts deleted file mode 100644 index ef36d90..0000000 --- a/src/identity-and-account/oauth-sessions/dtos/create-oauth-session.dto.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { ApiProperty } from "@nestjs/swagger"; -import { Type } from "class-transformer"; -import { IsArray, IsDate, IsOptional, IsString, IsUUID } from "class-validator"; - -export class CreateOauthSessionDto { - @ApiProperty({ - example: 'cklwi0vb70000z2z20q6f19qk', - description: 'Unique ID of an OAuth token (auto-generated)', - }) - id: string; - - @ApiProperty({ - example: 'S7A2U8R7O6N6', - description: 'User`s unique identification number', - }) - @IsUUID() - user_id: string; - - @ApiProperty({ - example: 'app.targo.ca', - description: 'URL in which the access token is used for', - }) - @IsString() - application: string; - - @IsString() - sid: string; - - @ApiProperty({ - example: 'L5O6R4D3/O6F3#T8H4E3&R6I4N6G4S7 ...', - description: 'Access token', - }) - @IsString() - access_token: string; - - @ApiProperty({ - example: 'Th3731102h1p07Th3R1n92', - description: 'Refresh token', - }) - @IsString() - refresh_token: string; - - @ApiProperty({ - example: '25/12/3018', - description: 'Access token`s expiry date', - }) - @Type(()=> Date) - @IsDate() - access_token_expiry: Date; - - @ApiProperty({ - example: '26/02/3019', - description: 'Refresh token`s expiry date', - required: false, - }) - @Type(()=> Date) - @IsDate() - @IsOptional() - refresh_token_expiry?: Date; - - @ApiProperty({ - example: 'access tolkiens, email, etc... ', - description: 'scopes of infos linked to the access token', - required: false, - }) - @IsArray() - @IsString() - @IsOptional() - scopes?: string[]; -} diff --git a/src/identity-and-account/oauth-sessions/dtos/update-oauth-session.dto.ts b/src/identity-and-account/oauth-sessions/dtos/update-oauth-session.dto.ts deleted file mode 100644 index 697efd7..0000000 --- a/src/identity-and-account/oauth-sessions/dtos/update-oauth-session.dto.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { PartialType } from "@nestjs/swagger"; -import { CreateOauthSessionDto } from "./create-oauth-session.dto"; - -export class UpdateOauthSessionDto extends PartialType(CreateOauthSessionDto) {} diff --git a/src/identity-and-account/oauth-sessions/oauth-sessions.module.ts b/src/identity-and-account/oauth-sessions/oauth-sessions.module.ts deleted file mode 100644 index e68a481..0000000 --- a/src/identity-and-account/oauth-sessions/oauth-sessions.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Module } from '@nestjs/common'; -import { PrismaService } from 'src/prisma/prisma.service'; -import { OauthSessionsController } from './controllers/oauth-sessions.controller'; -import { OauthSessionsService } from './services/oauth-sessions.service'; - -@Module({ - controllers: [OauthSessionsController], - providers: [OauthSessionsService, PrismaService] -}) -export class OauthSessionsModule {} diff --git a/src/identity-and-account/oauth-sessions/services/oauth-sessions.service.ts b/src/identity-and-account/oauth-sessions/services/oauth-sessions.service.ts deleted file mode 100644 index c307682..0000000 --- a/src/identity-and-account/oauth-sessions/services/oauth-sessions.service.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { Injectable, NotFoundException } from '@nestjs/common'; -import { PrismaService } from 'src/prisma/prisma.service'; -import { CreateOauthSessionDto } from '../dtos/create-oauth-session.dto'; -import { OAuthSessions } from '@prisma/client'; -import { UpdateOauthSessionDto } from '../dtos/update-oauth-session.dto'; - -@Injectable() -export class OauthSessionsService { - constructor(private readonly prisma: PrismaService) {} - - async create(dto: CreateOauthSessionDto): Promise { - const { - user_id, - application, - access_token, - refresh_token, - sid, - access_token_expiry, - refresh_token_expiry, - scopes, - } = dto; - - return this.prisma.oAuthSessions.create({ - data: { - user_id, - application, - access_token, - refresh_token, - sid, - access_token_expiry, - refresh_token_expiry, - scopes, - }, - include: { user: true }, - }); - } - - findAll(): Promise { - return this.prisma.oAuthSessions.findMany({ - include: { user: true }, - }); - } - - async findOne(id: string): Promise { - const token = await this.prisma.oAuthSessions.findUnique({ - where: { id }, - include: { user: true }, - }); - if(!token) { - throw new NotFoundException(`token #${ id } not found`); - } - return token; - } - - async update(id: string, dto: UpdateOauthSessionDto): Promise { - await this.findOne(id); - const { - user_id, - application, - access_token, - refresh_token, - access_token_expiry, - refresh_token_expiry, - scopes, - } = dto; - - return this.prisma.oAuthSessions.update({ - where: { id }, - data: { - ...(user_id !== undefined && { user_id }), - ...(application !== undefined && { application }), - ...(access_token !== undefined && { access_token }), - ...(refresh_token !== undefined && { refresh_token }), - ...(access_token_expiry !== undefined && { access_token_expiry }), - ...(refresh_token_expiry !== undefined && { refresh_token_expiry }), - ...(scopes !== undefined && { scopes }), - }, - include: { user: true }, - }); - } - - async remove(id: string): Promise { - await this.findOne(id); - return this.prisma.oAuthSessions.delete({ where: { id }}); - } -} diff --git a/src/time-and-attendance/modules/time-tracker/timesheets/helpers/timesheets-date-time-helpers.ts b/src/time-and-attendance/modules/time-tracker/timesheets/helpers/timesheets-date-time-helpers.ts index fab7730..3b06344 100644 --- a/src/time-and-attendance/modules/time-tracker/timesheets/helpers/timesheets-date-time-helpers.ts +++ b/src/time-and-attendance/modules/time-tracker/timesheets/helpers/timesheets-date-time-helpers.ts @@ -24,7 +24,7 @@ export const toStringFromDate = (date: Date | string): string => { const year = d.getUTCFullYear(); const month = String(d.getUTCMonth() + 1).padStart(2, '0'); const day = String(d.getUTCDate()).padStart(2, '0'); - return `${year}-${month}-${d}`; + return `${year}-${month}-${day}`; } export const toHHmmFromDate = (input: Date | string): string => {