From a16c4c564a5c81fbe46326591ca574c09069fcee Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Tue, 22 Dec 2020 11:27:21 +0100 Subject: [PATCH] Users now can be disabled from the start ref #40 --- src/models/actions/CreateUser.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/models/actions/CreateUser.ts b/src/models/actions/CreateUser.ts index 3839f11..0203d99 100644 --- a/src/models/actions/CreateUser.ts +++ b/src/models/actions/CreateUser.ts @@ -1,5 +1,5 @@ import * as argon2 from "argon2"; -import { IsEmail, IsOptional, IsPhoneNumber, IsString } from 'class-validator'; +import { IsBoolean, IsEmail, IsOptional, IsPhoneNumber, IsString } from 'class-validator'; import { getConnectionManager } from 'typeorm'; import * as uuid from 'uuid'; import { config } from '../../config'; @@ -63,6 +63,14 @@ export class CreateUser { @IsString() password: string; + /** + * Will the new user be enabled from the start? + * Default: true + */ + @IsBoolean() + @IsOptional() + enabled?: boolean = true; + /** * The new user's groups' id(s). * You can provide either one groupId or an array of groupIDs. @@ -91,6 +99,7 @@ export class CreateUser { newUser.phone = this.phone newUser.password = await argon2.hash(this.password + newUser.uuid); newUser.groups = await this.getGroups(); + newUser.enabled = this.enabled; //TODO: ProfilePics return newUser;