🚧 reference new Errors from CreateUser
This commit is contained in:
parent
091b455460
commit
1efca47336
|
@ -1,8 +1,10 @@
|
|||
import * as argon2 from "argon2";
|
||||
import { IsInt, IsOptional, IsPhoneNumber, IsString, IsUUID } from 'class-validator';
|
||||
import { IsEmail, IsOptional, IsPhoneNumber, IsString, IsUUID } from 'class-validator';
|
||||
import { getConnectionManager } from 'typeorm';
|
||||
import * as uuid from 'uuid';
|
||||
import { UserGroupNotFoundError, UsernameOrEmailNeededError } from '../../errors/CreateUserErrors';
|
||||
import { UsernameOrEmailNeededError } from '../../errors/UserErrors';
|
||||
import { User } from '../entities/User';
|
||||
import { UserGroup } from '../entities/UserGroup';
|
||||
|
||||
export class CreateUser {
|
||||
@IsString()
|
||||
|
@ -19,9 +21,11 @@ export class CreateUser {
|
|||
password: string;
|
||||
@IsString()
|
||||
lastname: string;
|
||||
@IsEmail()
|
||||
@IsString()
|
||||
email?: string;
|
||||
@IsInt()
|
||||
// @IsArray()
|
||||
// @IsInt()
|
||||
@IsOptional()
|
||||
groupId?: number[] | number
|
||||
@IsUUID("4")
|
||||
|
@ -36,9 +40,13 @@ export class CreateUser {
|
|||
|
||||
if (this.groupId) {
|
||||
// TODO: link user groups
|
||||
// newUser.groups = await getConnectionManager().get().getRepository(UserGroup).findOne({ id: this.teamId });
|
||||
if (Array.isArray(this.groupId)) {
|
||||
|
||||
} else {
|
||||
newUser.groups = await getConnectionManager().get().getRepository(UserGroup).find({ id: this.groupId });
|
||||
}
|
||||
} else {
|
||||
throw new UserGroupNotFoundError();
|
||||
// throw new UserGroupNotFoundError();
|
||||
}
|
||||
|
||||
const new_uuid = uuid.v4()
|
||||
|
|
Loading…
Reference in New Issue