mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 17:08:34 +00:00
bulk upload user fix
This commit is contained in:
parent
8301a4c4c3
commit
2e7246cca7
3 changed files with 35 additions and 23 deletions
|
|
@ -175,6 +175,17 @@ class ManageOrgUsersComponent extends React.Component {
|
|||
});
|
||||
})
|
||||
.catch(({ error }) => {
|
||||
if (error?.error) {
|
||||
this.setState({
|
||||
showErrorModal: true,
|
||||
errorModalMessage: error.error,
|
||||
errorTitle: error?.title || 'Conflicting permissions',
|
||||
errorItemList: error?.data,
|
||||
errorIconName: 'usergear',
|
||||
});
|
||||
this.setState({ creatingUser: false });
|
||||
return;
|
||||
}
|
||||
toast.error(error, {
|
||||
position: 'top-center',
|
||||
style: {
|
||||
|
|
@ -246,14 +257,18 @@ class ManageOrgUsersComponent extends React.Component {
|
|||
});
|
||||
})
|
||||
.catch(({ error }) => {
|
||||
this.setState({
|
||||
showErrorModal: true,
|
||||
errorModalMessage: error.error,
|
||||
errorTitle: error?.title || 'Conflicting permissions',
|
||||
errorItemList: error?.data,
|
||||
errorIconName: 'usergear',
|
||||
});
|
||||
this.setState({ creatingUser: false });
|
||||
if (error?.error) {
|
||||
this.setState({
|
||||
showErrorModal: true,
|
||||
errorModalMessage: error.error,
|
||||
errorTitle: error?.title || 'Conflicting permissions',
|
||||
errorItemList: error?.data,
|
||||
errorIconName: 'usergear',
|
||||
});
|
||||
this.setState({ creatingUser: false });
|
||||
return;
|
||||
}
|
||||
toast.error(error);
|
||||
});
|
||||
} else {
|
||||
this.setState({ creatingUser: false, file: null, isInviteUsersDrawerOpen: true });
|
||||
|
|
|
|||
|
|
@ -103,15 +103,11 @@ export class GroupPermissionsUtilityService {
|
|||
const { organizationId, userId, groupsToAddIds } = functionParam;
|
||||
return await dbTransactionWrap(async (manager: EntityManager) => {
|
||||
const userRole = await this.getUserRole(userId, organizationId, manager);
|
||||
console.log('this is running');
|
||||
|
||||
if (userRole.name === USER_ROLE.END_USER) {
|
||||
return await Promise.all(
|
||||
groupsToAddIds.map(async (id) => {
|
||||
const group = await manager.findOne(GroupPermissions, id);
|
||||
const isEditableGroup = await this.isEditableGroup(group, manager);
|
||||
console.log(isEditableGroup);
|
||||
|
||||
if (isEditableGroup) {
|
||||
throw new BadRequestException({
|
||||
message: {
|
||||
|
|
|
|||
|
|
@ -571,6 +571,10 @@ export class OrganizationsService {
|
|||
email: inviteNewUserDto.email,
|
||||
...getUserStatusAndSource(lifecycleEvents.USER_INVITE),
|
||||
};
|
||||
console.log('user is');
|
||||
|
||||
console.log(inviteNewUserDto);
|
||||
|
||||
const groups = inviteNewUserDto?.groups;
|
||||
const role = inviteNewUserDto.role;
|
||||
return await dbTransactionWrap(async (manager: EntityManager) => {
|
||||
|
|
@ -634,8 +638,10 @@ export class OrganizationsService {
|
|||
true,
|
||||
manager
|
||||
);
|
||||
console.log('good till here');
|
||||
|
||||
await this.usersService.attachUserGroup(groups, currentOrganization.id, user.id, manager);
|
||||
console.log('not good till here');
|
||||
const name = fullName(currentUser.firstName, currentUser.lastName);
|
||||
if (shouldSendWelcomeMail) {
|
||||
this.emailService
|
||||
|
|
@ -696,7 +702,7 @@ export class OrganizationsService {
|
|||
const archivedUsers = [];
|
||||
const invalidRows = [];
|
||||
const invalidFields = new Set();
|
||||
const invalidGroups = [];
|
||||
let invalidGroups = [];
|
||||
const emailPattern = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
|
||||
const manager = getManager();
|
||||
const invalidRoles = [];
|
||||
|
|
@ -710,9 +716,12 @@ export class OrganizationsService {
|
|||
ignoreEmpty: true,
|
||||
})
|
||||
.transform((row: UserCsvRow, next) => {
|
||||
const groupNames = this.createGroupsList(row?.groups);
|
||||
invalidGroups = [...invalidGroups, ...groupNames.filter((group) => !existingGroups.includes(group))];
|
||||
const groups = groupPermissions.filter((group) => groupNames.includes(group.name)).map((group) => group.id);
|
||||
return next(null, {
|
||||
...row,
|
||||
groups: this.createGroupsList(row?.groups),
|
||||
groups: groups,
|
||||
user_role: this.convertUserRolesCasing(row?.user_role),
|
||||
});
|
||||
})
|
||||
|
|
@ -720,6 +729,7 @@ export class OrganizationsService {
|
|||
await dbTransactionWrap(async (manager: EntityManager) => {
|
||||
//Check for existing users
|
||||
let isInvalidRole = false;
|
||||
|
||||
const user = await this.usersService.findByEmail(data?.email, undefined, undefined, manager);
|
||||
|
||||
if (user?.status === USER_STATUS.ARCHIVED) {
|
||||
|
|
@ -738,15 +748,6 @@ export class OrganizationsService {
|
|||
}
|
||||
|
||||
//Check for invalid groups
|
||||
const receivedGroups: string[] | null = data?.groups.length ? data?.groups : null;
|
||||
|
||||
if (Array.isArray(receivedGroups)) {
|
||||
for (const group of receivedGroups) {
|
||||
if (existingGroups.indexOf(group) === -1) {
|
||||
invalidGroups.push(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!Object.values(USER_ROLE).includes(data?.user_role as USER_ROLE)) {
|
||||
invalidRoles.push(data?.user_role);
|
||||
|
|
|
|||
Loading…
Reference in a new issue