mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 17:08:34 +00:00
constant fix
This commit is contained in:
parent
fb5f218769
commit
0abaa754ba
5 changed files with 7 additions and 26 deletions
|
|
@ -21,7 +21,8 @@ export const EDIT_ROLE_MESSAGE = {
|
|||
return (
|
||||
<div>
|
||||
<p className="tj-text-sm" style={{ marginBottom: '10px' }}>
|
||||
This will also remove the user from any custom groups with builder-like permissions.
|
||||
Changing your user group from admin to end-user will revoke your access to settings. This will also remove
|
||||
the user from any custom groups with builder-like permissions.
|
||||
{isPaidPlan && 'This will also affect the count of users covered by your plan.'}
|
||||
</p>
|
||||
<p className="tj-text-sm">Are you sure you want to continue?</p>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { BadRequestException, Injectable } from '@nestjs/common';
|
|||
import { GroupPermissions } from 'src/entities/group_permissions.entity';
|
||||
import { User } from 'src/entities/user.entity';
|
||||
import {
|
||||
ERROR_HANDLER,
|
||||
GROUP_PERMISSIONS_TYPE,
|
||||
USER_ROLE,
|
||||
} from '@module/user_resource_permissions/constants/group-permissions.constant';
|
||||
|
|
@ -107,6 +108,7 @@ export class GroupPermissionsUtilityService {
|
|||
return await Promise.all(
|
||||
groupsToAddIds.map(async (id) => {
|
||||
const group = await manager.findOne(GroupPermissions, id);
|
||||
if (!group) throw new BadRequestException(ERROR_HANDLER.GROUP_NOT_EXIST);
|
||||
const isEditableGroup = await this.isEditableGroup(group, manager);
|
||||
if (isEditableGroup) {
|
||||
throw new BadRequestException({
|
||||
|
|
|
|||
|
|
@ -136,8 +136,6 @@ export function getAllUserGroupsQuery(
|
|||
}
|
||||
|
||||
export function validateCreateGroupOperation(createGroupPermissionDto: CreateGroupPermissionDto) {
|
||||
console.log('this is running');
|
||||
|
||||
const humanizeList = ['End-user', 'Builder', 'Admin'];
|
||||
|
||||
if (humanizeList.includes(createGroupPermissionDto.name)) {
|
||||
|
|
|
|||
|
|
@ -242,13 +242,14 @@ export class AuthService {
|
|||
organizationId: user.organizationId,
|
||||
resources: [{ resource: TOOLJET_RESOURCE.APP }],
|
||||
});
|
||||
const isAdmin = !!permissions.find((permission) => permission.name === USER_ROLE.ADMIN);
|
||||
const appGroupPermissions = userPermissions?.[TOOLJET_RESOURCE.APP];
|
||||
delete userPermissions?.[TOOLJET_RESOURCE.APP];
|
||||
return decamelizeKeys({
|
||||
currentOrganizationId: user.organizationId,
|
||||
currentOrganizationSlug: organization.slug,
|
||||
currentOrganizationName: organization.name,
|
||||
admin: await this.usersService.hasGroup(user, USER_ROLE.ADMIN, null, manager),
|
||||
admin: isAdmin,
|
||||
userPermissions: userPermissions,
|
||||
groupPermissions: permissions.filter(
|
||||
(group) => group.type === GROUP_PERMISSIONS_TYPE.CUSTOM_GROUP || group.name === USER_ROLE.ADMIN
|
||||
|
|
|
|||
|
|
@ -8,16 +8,12 @@ import { BadRequestException } from '@nestjs/common';
|
|||
import { cleanObject, dbTransactionWrap } from 'src/helpers/utils.helper';
|
||||
import { CreateFileDto } from '@dto/create-file.dto';
|
||||
import { USER_STATUS, WORKSPACE_USER_STATUS } from 'src/helpers/user_lifecycle';
|
||||
import {
|
||||
GROUP_PERMISSIONS_TYPE,
|
||||
USER_ROLE,
|
||||
} from '@module/user_resource_permissions/constants/group-permissions.constant';
|
||||
import { USER_ROLE } from '@module/user_resource_permissions/constants/group-permissions.constant';
|
||||
import { GroupPermissionsServiceV2 } from './group_permissions.service.v2';
|
||||
import { UserRoleService } from './user-role.service';
|
||||
import { validateDeleteGroupUserOperation } from '@module/user_resource_permissions/utility/group-permissions.utility';
|
||||
import { GroupPermissionsUtilityService } from '@module/user_resource_permissions/services/group-permissions.utility.service';
|
||||
import { Organization } from 'src/entities/organization.entity';
|
||||
import { GroupPermissions } from 'src/entities/group_permissions.entity';
|
||||
const uuid = require('uuid');
|
||||
const bcrypt = require('bcrypt');
|
||||
|
||||
|
|
@ -227,23 +223,6 @@ export class UsersService {
|
|||
if (isAdmin && allActiveAdmin.length < 2) throw new BadRequestException('Atleast one active admin is required');
|
||||
}
|
||||
|
||||
async hasGroup(user: User, role: USER_ROLE, organizationId?: string, manager?: EntityManager): Promise<boolean> {
|
||||
return await dbTransactionWrap(async (manager: EntityManager) => {
|
||||
const result = await manager
|
||||
.createQueryBuilder(GroupPermissions, 'group_permissions')
|
||||
.innerJoin('group_permissions.groupUsers', 'groupUsers')
|
||||
.where('group_permissions.organizationId = :organizationId', {
|
||||
organizationId: organizationId || user.organizationId,
|
||||
})
|
||||
.andWhere('group_permissions.name = :role ', { role })
|
||||
.andWhere('group_permissions.type = :type', { type: GROUP_PERMISSIONS_TYPE.DEFAULT })
|
||||
.andWhere('groupUsers.userId = :userId', { userId: user.id })
|
||||
.getCount();
|
||||
|
||||
return result > 0;
|
||||
}, manager);
|
||||
}
|
||||
|
||||
async returnOrgIdOfAnApp(slug: string): Promise<{ organizationId: string; isPublic: boolean }> {
|
||||
let app: App;
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in a new issue