Merge branch 'main' of git.targo.ca:Targo/targo_backend into dev/setup/modules/MatthieuH
This commit is contained in:
commit
91ef6685b4
|
|
@ -545,34 +545,6 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"/timesheets/{id}/approval": {
|
||||
"patch": {
|
||||
"operationId": "TimesheetsController_approve",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"in": "path",
|
||||
"schema": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"access-token": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Timesheets"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/Expenses": {
|
||||
"post": {
|
||||
"operationId": "ExpensesController_create",
|
||||
|
|
@ -1225,34 +1197,6 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"/leave-requests/{id}/approval": {
|
||||
"patch": {
|
||||
"operationId": "LeaveRequestController_updateApproval",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "id",
|
||||
"required": true,
|
||||
"in": "path",
|
||||
"schema": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"access-token": []
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Leave Requests"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/auth/v1/login": {
|
||||
"get": {
|
||||
"operationId": "AuthController_login",
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@ import {
|
|||
import { Reflector } from '@nestjs/core';
|
||||
import { ROLES_KEY } from '../decorators/roles.decorators';
|
||||
import { Roles } from '.prisma/client';
|
||||
import { JwtPayload } from 'src/modules/authentication/strategies/jwt.strategy';
|
||||
|
||||
|
||||
|
||||
interface RequestWithUser extends Request {
|
||||
user: JwtPayload;
|
||||
// TODO: Create an actual user model based on OAuth signin
|
||||
user: any;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
|
|
|
|||
|
|
@ -2,11 +2,10 @@ import { Controller, Get, NotFoundException, Param, ParseIntPipe, UseGuards } fr
|
|||
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
import { EmployeesArchive, Roles as RoleEnum } from '@prisma/client';
|
||||
import { JwtAuthGuard } from "src/modules/authentication/guards/jwt-auth.guard";
|
||||
import { EmployeesService } from "src/modules/employees/services/employees.service";
|
||||
|
||||
@ApiTags('Employee Archives')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
// @UseGuards()
|
||||
@Controller('archives/employees')
|
||||
export class EmployeesArchiveController {
|
||||
constructor(private readonly employeesService: EmployeesService) {}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,10 @@ import { UseGuards, Controller, Get, Param, ParseIntPipe, NotFoundException } fr
|
|||
import { ApiTags, ApiOperation, ApiResponse } from "@nestjs/swagger";
|
||||
import { ExpensesArchive,Roles as RoleEnum } from "@prisma/client";
|
||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
import { JwtAuthGuard } from "src/modules/authentication/guards/jwt-auth.guard";
|
||||
import { ExpensesService } from "src/modules/expenses/services/expenses.service";
|
||||
|
||||
@ApiTags('Expense Archives')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
// @UseGuards()
|
||||
@Controller('archives/expenses')
|
||||
export class ExpensesArchiveController {
|
||||
constructor(private readonly expensesService: ExpensesService) {}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,10 @@ import { Get, Param, ParseIntPipe, NotFoundException, Controller, UseGuards } fr
|
|||
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||
import { LeaveRequestsArchive, Roles as RoleEnum } from "@prisma/client";
|
||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
import { JwtAuthGuard } from "src/modules/authentication/guards/jwt-auth.guard";
|
||||
import { LeaveRequestsService } from "src/modules/leave-requests/services/leave-requests.service";
|
||||
|
||||
@ApiTags('LeaveRequests Archives')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
// @UseGuards()
|
||||
@Controller('archives/leaveRequests')
|
||||
export class LeaveRequestsArchiveController {
|
||||
constructor(private readonly leaveRequestsService: LeaveRequestsService) {}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,10 @@ import { Get, Param, ParseIntPipe, NotFoundException, Controller, UseGuards } fr
|
|||
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||
import { ShiftsArchive, Roles as RoleEnum } from "@prisma/client";
|
||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
import { JwtAuthGuard } from "src/modules/authentication/guards/jwt-auth.guard";
|
||||
import { ShiftsService } from "src/modules/shifts/services/shifts.service";
|
||||
|
||||
@ApiTags('Shift Archives')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
// @UseGuards()
|
||||
@Controller('archives/shifts')
|
||||
export class ShiftsArchiveController {
|
||||
constructor(private readonly shiftsService:ShiftsService) {}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,9 @@ import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
|||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
import { TimesheetsArchive, Roles as RoleEnum } from '@prisma/client';
|
||||
import { TimesheetsService } from "src/modules/timesheets/services/timesheets.service";
|
||||
import { JwtAuthGuard } from "src/modules/authentication/guards/jwt-auth.guard";
|
||||
|
||||
@ApiTags('Timesheet Archives')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
// @UseGuards()
|
||||
@Controller('archives/timesheets')
|
||||
export class TimesheetsArchiveController {
|
||||
constructor(private readonly timesheetsService: TimesheetsService) {}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { JwtModule } from '@nestjs/jwt';
|
||||
import { PassportModule } from '@nestjs/passport';
|
||||
import { AuthentikAuthService } from './services/authentik-auth.service';
|
||||
import { UsersModule } from '../users-management/users.module';
|
||||
import { AuthController } from './controllers/auth.controller';
|
||||
import { AuthentikStrategy } from './strategies/authentik.strategy';
|
||||
import { SessionSerializer } from './session.serializer';
|
||||
import { ExpressSessionSerializer } from './services/express-session.serializer';
|
||||
|
||||
|
||||
@Module({
|
||||
|
|
@ -16,7 +15,7 @@ import { SessionSerializer } from './session.serializer';
|
|||
providers: [
|
||||
AuthentikAuthService,
|
||||
AuthentikStrategy,
|
||||
SessionSerializer,
|
||||
ExpressSessionSerializer,
|
||||
],
|
||||
exports: [ AuthentikAuthService ],
|
||||
controllers: [AuthController],
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
POST http://localhost:3000/auth/login
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
import { ExecutionContext, Injectable, UnauthorizedException } from '@nestjs/common';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class JwtAuthGuard extends AuthGuard('jwt') {
|
||||
|
||||
canActivate(context: ExecutionContext) {
|
||||
return super.canActivate(context);
|
||||
}
|
||||
|
||||
handleRequest(err, user, info) {
|
||||
if(err || !user) {
|
||||
throw err || new UnauthorizedException();
|
||||
}
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ import { PassportSerializer } from '@nestjs/passport';
|
|||
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class SessionSerializer extends PassportSerializer {
|
||||
export class ExpressSessionSerializer extends PassportSerializer {
|
||||
serializeUser(user: any, done: (err: any, user: any) => void): any {
|
||||
if (!user){
|
||||
done(new UnauthorizedException('Serialize user error'), user);
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { UUID } from 'crypto';
|
||||
import { UsersService } from 'src/modules/users-management/services/users.service';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
constructor(
|
||||
private usersService: UsersService,
|
||||
private jwtService: JwtService
|
||||
) {}
|
||||
|
||||
async validateUser(user_id: UUID): Promise<any> {
|
||||
const user = await this.usersService.findOne( user_id );
|
||||
if (user) {
|
||||
return user;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { PassportStrategy } from '@nestjs/passport';
|
||||
import { Roles } from '@prisma/client';
|
||||
import { ExtractJwt, Strategy } from 'passport-jwt';
|
||||
|
||||
export interface JwtPayload {
|
||||
sub: number;
|
||||
email: string;
|
||||
role: Roles;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class JwtStrategy extends PassportStrategy(Strategy) {
|
||||
constructor() {
|
||||
super({
|
||||
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
||||
ignoreExpiration: false,
|
||||
secretOrKey: process.env.JWT_SECRET || 'CHANGE_ME',
|
||||
});
|
||||
}
|
||||
|
||||
validate(payload: JwtPayload): JwtPayload {
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
|
|
@ -6,12 +6,11 @@ import { UpdateCustomerDto } from '../dtos/update-customer.dto';
|
|||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
import { Roles as RoleEnum } from '.prisma/client';
|
||||
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { JwtAuthGuard } from 'src/modules/authentication/guards/jwt-auth.guard';
|
||||
import { CustomerEntity } from '../dtos/swagger-entities/customers.entity';
|
||||
|
||||
@ApiTags('Customers')
|
||||
@ApiBearerAuth('access-token')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
// @UseGuards()
|
||||
@Controller('customers')
|
||||
export class CustomersController {
|
||||
constructor(private readonly customersService: CustomersService) {}
|
||||
|
|
|
|||
|
|
@ -5,12 +5,11 @@ import { CreateEmployeeDto } from '../dtos/create-employee.dto';
|
|||
import { UpdateEmployeeDto } from '../dtos/update-employee.dto';
|
||||
import { RolesAllowed } from '../../../common/decorators/roles.decorators';
|
||||
import { ApiBearerAuth, ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { JwtAuthGuard } from 'src/modules/authentication/guards/jwt-auth.guard';
|
||||
import { EmployeeEntity } from '../dtos/swagger-entities/employees.entity';
|
||||
|
||||
@ApiTags('Employees')
|
||||
@ApiBearerAuth('access-token')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
// @UseGuards()
|
||||
@Controller('employees')
|
||||
export class EmployeesController {
|
||||
constructor(private readonly employeesService: EmployeesService) {}
|
||||
|
|
|
|||
|
|
@ -6,14 +6,13 @@ import { Roles as RoleEnum } from '.prisma/client';
|
|||
import { UpdateExpenseDto } from "../dtos/update-expense.dto";
|
||||
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
import { JwtAuthGuard } from "src/modules/authentication/guards/jwt-auth.guard";
|
||||
import { ExpenseEntity } from "../dtos/swagger-entities/expenses.entity";
|
||||
import { ExpensesApprovalService } from "../services/expenses-approval.service";
|
||||
import { SearchExpensesDto } from "../dtos/search-expense.dto";
|
||||
|
||||
@ApiTags('Expenses')
|
||||
@ApiBearerAuth('access-token')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
// @UseGuards()
|
||||
@Controller('Expenses')
|
||||
export class ExpensesController {
|
||||
constructor(
|
||||
|
|
|
|||
|
|
@ -6,13 +6,12 @@ import { UpdateLeaveRequestsDto } from "../dtos/update-leave-requests.dto";
|
|||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
import { LeaveApprovalStatus, Roles as RoleEnum } from '.prisma/client';
|
||||
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||
import { JwtAuthGuard } from "src/modules/authentication/guards/jwt-auth.guard";
|
||||
import { LeaveRequestEntity } from "../dtos/swagger-entities/leave-requests.entity";
|
||||
import { SearchLeaveRequestsDto } from "../dtos/search-leave-requests.dto";
|
||||
|
||||
@ApiTags('Leave Requests')
|
||||
@ApiBearerAuth('access-token')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
// @UseGuards()
|
||||
@Controller('leave-requests')
|
||||
export class LeaveRequestController {
|
||||
constructor(private readonly leaveRequetsService: LeaveRequestsService){}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ 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 { JwtAuthGuard } from 'src/modules/authentication/guards/jwt-auth.guard';
|
||||
import { CreateOauthSessionDto } from '../dtos/create-oauth-sessions.dto';
|
||||
import { OauthSessionsService } from '../services/oauth-sessions.service';
|
||||
import { OAuthSessionEntity } from '../dtos/swagger-entities/oauth-sessions.entity';
|
||||
|
|
@ -11,7 +10,7 @@ import { UpdateOauthSessionDto } from '../dtos/update-oauth-sessions.dto';
|
|||
|
||||
@ApiTags('OAuth Sessions')
|
||||
@ApiBearerAuth('sessions')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
//@UseGuards(JwtAuthGuard)
|
||||
@Controller('oauth-sessions')
|
||||
export class OauthSessionsController {
|
||||
constructor(private readonly oauthSessionsService: OauthSessionsService){}
|
||||
|
|
|
|||
|
|
@ -6,14 +6,13 @@ import { UpdateShiftsDto } from "../dtos/update-shift.dto";
|
|||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
import { Roles as RoleEnum } from '.prisma/client';
|
||||
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||
import { JwtAuthGuard } from "src/modules/authentication/guards/jwt-auth.guard";
|
||||
import { ShiftEntity } from "../dtos/swagger-entities/shift.entity";
|
||||
import { ShiftsApprovalService } from "../services/shifts-approval.service";
|
||||
import { SearchShiftsDto } from "../dtos/search-shifts.dto";
|
||||
|
||||
@ApiTags('Shifts')
|
||||
@ApiBearerAuth('access-token')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
// @UseGuards()
|
||||
@Controller('shifts')
|
||||
export class ShiftsController {
|
||||
constructor(
|
||||
|
|
|
|||
|
|
@ -6,14 +6,13 @@ import { UpdateTimesheetDto } from '../dtos/update-timesheet.dto';
|
|||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||
import { Roles as RoleEnum } from '.prisma/client';
|
||||
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { JwtAuthGuard } from 'src/modules/authentication/guards/jwt-auth.guard';
|
||||
import { TimesheetEntity } from '../dtos/swagger-entities/timesheet.entity';
|
||||
import { TimesheetsApprovalService } from '../services/timesheets-approval.service';
|
||||
import { SearchTimesheetDto } from '../dtos/search-timesheets.dto';
|
||||
|
||||
@ApiTags('Timesheets')
|
||||
@ApiBearerAuth('access-token')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
// @UseGuards()
|
||||
@Controller('timesheets')
|
||||
export class TimesheetsController {
|
||||
constructor(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user