mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-12 15:49:09 +00:00
FIX: adding error message on each failed user (BatchCreateUserRes)
This commit is contained in:
@@ -79,11 +79,19 @@ export class BatchCreateUserReq {
|
||||
@ApiProperty({ type: [CreateUserReq] })
|
||||
users: CreateUserReq[];
|
||||
}
|
||||
|
||||
class ErrorUsers {
|
||||
@ApiProperty({ type: [CreateUserReq] })
|
||||
user: CreateUserReq;
|
||||
@ApiProperty()
|
||||
error: string;
|
||||
}
|
||||
|
||||
export class BatchCreateUserRes {
|
||||
@ApiProperty({ type: [User] })
|
||||
usersCreated: User[];
|
||||
@ApiProperty({ type: [CreateUserReq] })
|
||||
errorUsers: CreateUserReq[];
|
||||
@ApiProperty({ type: [ErrorUsers] })
|
||||
errorUsers: ErrorUsers[];
|
||||
}
|
||||
|
||||
export class UpdateUserReq {
|
||||
|
||||
@@ -22,6 +22,7 @@ import { RolesService } from '../roles/roles.service';
|
||||
import { HIERARCHIES } from './hierarchies';
|
||||
import { LanguageEnum } from 'src/utils/languages.enum';
|
||||
import { UserByCustomer } from 'protospack-v2/dist/lib/Duc/interfaces/entities';
|
||||
import { EnrichErrorCode } from 'src/utils/ErrorBuilder';
|
||||
|
||||
@Injectable()
|
||||
export class UsersService implements OnModuleInit {
|
||||
@@ -144,7 +145,15 @@ export class UsersService implements OnModuleInit {
|
||||
}),
|
||||
);
|
||||
this.adjustUsersPayload(usersCreated);
|
||||
return { errorUsers, usersCreated };
|
||||
|
||||
return {
|
||||
usersCreated,
|
||||
// mapping error code to message
|
||||
errorUsers: errorUsers.map(({ user, error }) => ({
|
||||
user,
|
||||
error: EnrichErrorCode(error).message,
|
||||
})),
|
||||
};
|
||||
}
|
||||
async assignRoleToUser(body: AssignRoleToUserRequest) {
|
||||
return lastValueFrom(this.usersClientService.AssignRoleToUser(body));
|
||||
|
||||
Reference in New Issue
Block a user