mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
* Fix: User group permissions error on Openshift platform (#4041) * update dockerfile for file permissions on root group * add permissions from the user group on dockerfile * bump to v1.24.4 * bump to v1.25.0 * [feature] Added pagination and filtering features to users page (#3921) * added pagination and filtering in backend * added pagination - created a seperate component for users table - added pagination * Added filter UI * temporary css fix for pagination footer * fixed pagination width issue * now result will also clear when user clicks on clear icon * Added seperate api for comment mentions * Now we can search mentions by email, first and last names * Fixed a bug - email didn't send for comment mentions * refactoring the code * resolved PR changes * Added isAdmin guard * adding some checks * fixed lint errors * added wild card search * Added no result found text * fixed failing test case * Working on PR changes * Now users table avatars will load image too * replaced skeleton classes with skeleton library component * Completed PR changes * added orderby * Fixed some issues * fixed failed test case * have fixed some css issues * replaced query with quersrting package * fixed minor width issue * Fixed some css issues * fixed darkMode issue * implemented on enter press search * Refactored the code * fixed white space issue * refactored the code * fixed overlapping issue * refactored the code * fixing some issues * fixes * removed guard * code cleanup * comments notification fix * fixed conflict issues * fixed css height issue Co-authored-by: gsmithun4 <gsmithun4@gmail.com> * Remove signup guard from set-password-from-token API (#4050) * Remove sign up guard set-password-from-token API * test cases fix * Bump to v1.25.1 * Feature: Add PG_DB_OWNER env var to disable db and extension creation (#4055) * add PG_DB_OWNER env var to disable db and extension creation * update docs * bump to v1.25.2 Co-authored-by: Akshay <akshaysasidharan93@gmail.com> Co-authored-by: Muhsin Shah C P <muhsinshah21@gmail.com>
87 lines
3.3 KiB
TypeScript
87 lines
3.3 KiB
TypeScript
import {
|
|
Controller,
|
|
Post,
|
|
UseGuards,
|
|
Body,
|
|
Get,
|
|
Patch,
|
|
Delete,
|
|
Param,
|
|
BadRequestException,
|
|
ForbiddenException,
|
|
} from '@nestjs/common';
|
|
import { decamelizeKeys } from 'humps';
|
|
import { JwtAuthGuard } from '../modules/auth/jwt-auth.guard';
|
|
import { User } from 'src/decorators/user.decorator';
|
|
import { CreateEnvironmentVariableDto, UpdateEnvironmentVariableDto } from '@dto/environment-variable.dto';
|
|
import { OrgEnvironmentVariablesService } from '@services/org_environment_variables.service';
|
|
import { OrgEnvironmentVariablesAbilityFactory } from 'src/modules/casl/abilities/org-environment-variables-ability.factory';
|
|
import { OrgEnvironmentVariable } from 'src/entities/org_envirnoment_variable.entity';
|
|
import { IsPublicGuard } from 'src/modules/org_environment_variables/is-public.guard';
|
|
import { App } from 'src/decorators/app.decorator';
|
|
|
|
@Controller('organization-variables')
|
|
export class OrgEnvironmentVariablesController {
|
|
constructor(
|
|
private orgEnvironmentVariablesService: OrgEnvironmentVariablesService,
|
|
private orgEnvironmentVariablesAbilityFactory: OrgEnvironmentVariablesAbilityFactory
|
|
) {}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Get()
|
|
async get(@User() user) {
|
|
const result = await this.orgEnvironmentVariablesService.fetchVariables(user.organizationId);
|
|
return decamelizeKeys({ variables: result });
|
|
}
|
|
|
|
@UseGuards(IsPublicGuard)
|
|
@Get(':app_slug')
|
|
async getVariablesFromApp(@App() app) {
|
|
const result = await this.orgEnvironmentVariablesService.fetchVariables(app.organizationId);
|
|
return decamelizeKeys({ variables: result });
|
|
}
|
|
|
|
// Endpoint for adding new env vars
|
|
@UseGuards(JwtAuthGuard)
|
|
@Post()
|
|
async create(@User() user, @Body() createEnvironmentVariableDto: CreateEnvironmentVariableDto) {
|
|
const ability = await this.orgEnvironmentVariablesAbilityFactory.orgEnvironmentVariableActions(user, {});
|
|
|
|
if (!ability.can('createOrgEnvironmentVariable', OrgEnvironmentVariable)) {
|
|
throw new ForbiddenException('You do not have permissions to perform this action');
|
|
}
|
|
|
|
const result = await this.orgEnvironmentVariablesService.create(user, createEnvironmentVariableDto);
|
|
return decamelizeKeys({ variable: result });
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Patch(':id')
|
|
async update(@Body() body: UpdateEnvironmentVariableDto, @User() user, @Param('id') variableId) {
|
|
const ability = await this.orgEnvironmentVariablesAbilityFactory.orgEnvironmentVariableActions(user, {});
|
|
|
|
if (!ability.can('updateOrgEnvironmentVariable', OrgEnvironmentVariable)) {
|
|
throw new ForbiddenException('You do not have permissions to perform this action');
|
|
}
|
|
|
|
await this.orgEnvironmentVariablesService.update(user.organizationId, variableId, body);
|
|
return {};
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Delete(':id')
|
|
async delete(@User() user, @Param('id') variableId) {
|
|
const ability = await this.orgEnvironmentVariablesAbilityFactory.orgEnvironmentVariableActions(user, {});
|
|
|
|
if (!ability.can('deleteOrgEnvironmentVariable', OrgEnvironmentVariable)) {
|
|
throw new ForbiddenException('You do not have permissions to perform this action');
|
|
}
|
|
|
|
const result = await this.orgEnvironmentVariablesService.delete(user.organizationId, variableId);
|
|
if (result.affected == 1) {
|
|
return;
|
|
} else {
|
|
throw new BadRequestException();
|
|
}
|
|
}
|
|
}
|