parent
dadaacfaae
commit
a42595bd15
|
@ -7,35 +7,71 @@ import { User } from '../entities/User';
|
|||
import { UserGroup } from '../entities/UserGroup';
|
||||
|
||||
export class CreateUser {
|
||||
/**
|
||||
* The new user's first name.
|
||||
*/
|
||||
@IsString()
|
||||
firstname: string;
|
||||
|
||||
/**
|
||||
* The new user's middle name.
|
||||
* Optinal.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
middlename?: string;
|
||||
|
||||
/**
|
||||
* The new user's last name.
|
||||
*/
|
||||
@IsString()
|
||||
lastname: string;
|
||||
|
||||
/**
|
||||
* The new user's username.
|
||||
* You have to provide at least one of: {email, username}.
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
username?: string;
|
||||
|
||||
@IsPhoneNumber("ZZ")
|
||||
@IsOptional()
|
||||
phone?: string;
|
||||
|
||||
@IsString()
|
||||
password: string;
|
||||
|
||||
@IsString()
|
||||
lastname: string;
|
||||
|
||||
/**
|
||||
* The new user's email address.
|
||||
* You have to provide at least one of: {email, username}.
|
||||
*/
|
||||
@IsEmail()
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
email?: string;
|
||||
|
||||
/**
|
||||
* The new user's phone number.
|
||||
* Optional
|
||||
*/
|
||||
@IsPhoneNumber("ZZ")
|
||||
@IsOptional()
|
||||
phone?: string;
|
||||
|
||||
/**
|
||||
* The new user's password.
|
||||
* This will of course not be saved in plaintext :)
|
||||
*/
|
||||
@IsString()
|
||||
password: string;
|
||||
|
||||
/**
|
||||
* The new user's groups' id(s).
|
||||
* You can provide either one groupId or an array of groupIDs.
|
||||
* Optional.
|
||||
*/
|
||||
@IsOptional()
|
||||
groupId?: number[] | number
|
||||
|
||||
//TODO: ProfilePics
|
||||
|
||||
/**
|
||||
* Converts this to a User Entity.
|
||||
*/
|
||||
public async toUser(): Promise<User> {
|
||||
let newUser: User = new User();
|
||||
|
||||
|
@ -75,8 +111,8 @@ export class CreateUser {
|
|||
newUser.uuid = uuid.v4()
|
||||
newUser.phone = this.phone
|
||||
newUser.password = await argon2.hash(this.password + newUser.uuid);
|
||||
//TODO: ProfilePics
|
||||
|
||||
console.log(newUser)
|
||||
return newUser;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue