parent
74ee77f814
commit
dadaacfaae
|
@ -9,21 +9,30 @@ import { UserGroup } from '../entities/UserGroup';
|
|||
export class CreateUser {
|
||||
@IsString()
|
||||
firstname: string;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
middlename?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
username?: string;
|
||||
|
||||
@IsPhoneNumber("ZZ")
|
||||
@IsOptional()
|
||||
phone?: string;
|
||||
|
||||
@IsString()
|
||||
password: string;
|
||||
|
||||
@IsString()
|
||||
lastname: string;
|
||||
|
||||
@IsEmail()
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
email?: string;
|
||||
|
||||
@IsOptional()
|
||||
groupId?: number[] | number
|
||||
|
||||
|
@ -58,15 +67,14 @@ export class CreateUser {
|
|||
}
|
||||
}
|
||||
|
||||
const new_uuid = uuid.v4()
|
||||
|
||||
newUser.email = this.email
|
||||
newUser.username = this.username
|
||||
newUser.firstname = this.firstname
|
||||
newUser.middlename = this.middlename
|
||||
newUser.lastname = this.lastname
|
||||
newUser.uuid = new_uuid
|
||||
newUser.password = await argon2.hash(this.password + new_uuid);
|
||||
newUser.uuid = uuid.v4()
|
||||
newUser.phone = this.phone
|
||||
newUser.password = await argon2.hash(this.password + newUser.uuid);
|
||||
|
||||
console.log(newUser)
|
||||
return newUser;
|
||||
|
|
|
@ -13,7 +13,6 @@ export class User {
|
|||
* autogenerated unique id (primary key).
|
||||
*/
|
||||
@PrimaryGeneratedColumn()
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
id: number;
|
||||
|
||||
|
@ -21,30 +20,30 @@ export class User {
|
|||
* uuid
|
||||
*/
|
||||
@Column()
|
||||
@IsUUID("4")
|
||||
@IsUUID(4)
|
||||
uuid: string;
|
||||
|
||||
/**
|
||||
* user email
|
||||
*/
|
||||
@Column()
|
||||
@Column({ nullable: true })
|
||||
@IsEmail()
|
||||
email: string;
|
||||
email?: string;
|
||||
|
||||
/**
|
||||
* user phone
|
||||
*/
|
||||
@Column()
|
||||
@IsPhoneNumber("ZZ")
|
||||
@Column({ nullable: true })
|
||||
@IsOptional()
|
||||
phone: string;
|
||||
@IsPhoneNumber("ZZ")
|
||||
phone?: string;
|
||||
|
||||
/**
|
||||
* username
|
||||
*/
|
||||
@Column()
|
||||
@Column({ nullable: true })
|
||||
@IsString()
|
||||
username: string;
|
||||
username?: string;
|
||||
|
||||
/**
|
||||
* firstname
|
||||
|
@ -57,10 +56,10 @@ export class User {
|
|||
/**
|
||||
* middlename
|
||||
*/
|
||||
@Column()
|
||||
@Column({ nullable: true })
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
middlename: string;
|
||||
middlename?: string;
|
||||
|
||||
/**
|
||||
* lastname
|
||||
|
@ -83,7 +82,7 @@ export class User {
|
|||
*/
|
||||
@IsOptional()
|
||||
@ManyToOne(() => Permission, permission => permission.users, { nullable: true })
|
||||
permissions: Permission[];
|
||||
permissions?: Permission[];
|
||||
|
||||
/**
|
||||
* groups
|
||||
|
@ -105,21 +104,22 @@ export class User {
|
|||
*/
|
||||
@IsInt()
|
||||
@Column({ default: 1 })
|
||||
refreshTokenCount: number;
|
||||
refreshTokenCount?: number;
|
||||
|
||||
/**
|
||||
* profilepic
|
||||
*/
|
||||
@Column()
|
||||
@Column({ nullable: true })
|
||||
@IsString()
|
||||
profilePic: string;
|
||||
@IsOptional()
|
||||
profilePic?: string;
|
||||
|
||||
/**
|
||||
* actions
|
||||
*/
|
||||
@IsOptional()
|
||||
@OneToMany(() => UserAction, action => action.user, { nullable: true })
|
||||
actions: UserAction
|
||||
actions: UserAction[]
|
||||
|
||||
/**
|
||||
* calculate all permissions
|
||||
|
|
Loading…
Reference in New Issue