latest work #20
@ -22,6 +22,7 @@
|
|||||||
],
|
],
|
||||||
"license": "CC-BY-NC-SA-4.0",
|
"license": "CC-BY-NC-SA-4.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"argon2": "^0.27.0",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"class-transformer": "^0.3.1",
|
"class-transformer": "^0.3.1",
|
||||||
"class-validator": "^0.12.2",
|
"class-validator": "^0.12.2",
|
||||||
@ -39,7 +40,8 @@
|
|||||||
"routing-controllers-openapi": "^2.1.0",
|
"routing-controllers-openapi": "^2.1.0",
|
||||||
"swagger-ui-express": "^4.1.5",
|
"swagger-ui-express": "^4.1.5",
|
||||||
"typeorm": "^0.2.29",
|
"typeorm": "^0.2.29",
|
||||||
"typeorm-routing-controllers-extensions": "^0.2.0"
|
"typeorm-routing-controllers-extensions": "^0.2.0",
|
||||||
|
"uuid": "^8.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/cors": "^2.8.8",
|
"@types/cors": "^2.8.8",
|
||||||
@ -49,6 +51,7 @@
|
|||||||
"@types/multer": "^1.4.4",
|
"@types/multer": "^1.4.4",
|
||||||
"@types/node": "^14.14.9",
|
"@types/node": "^14.14.9",
|
||||||
"@types/swagger-ui-express": "^4.1.2",
|
"@types/swagger-ui-express": "^4.1.2",
|
||||||
|
"@types/uuid": "^8.3.0",
|
||||||
"dotenv-safe": "^8.2.0",
|
"dotenv-safe": "^8.2.0",
|
||||||
"nodemon": "^2.0.6",
|
"nodemon": "^2.0.6",
|
||||||
"sqlite3": "^5.0.0",
|
"sqlite3": "^5.0.0",
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { IsInt, IsOptional, IsPhoneNumber, IsString } from 'class-validator';
|
import * as argon2 from "argon2";
|
||||||
import { User } from '../models/User';
|
import { IsInt, IsOptional, IsPhoneNumber, IsString, IsUUID } from 'class-validator';
|
||||||
import { getConnectionManager } from 'typeorm';
|
import * as uuid from 'uuid';
|
||||||
import { UserGroupNotFoundError, UsernameOrEmailNeededError } from '../errors/CreateUserErrors';
|
import { UserGroupNotFoundError, UsernameOrEmailNeededError } from '../errors/CreateUserErrors';
|
||||||
import { UserGroup } from './UserGroup';
|
import { User } from '../models/User';
|
||||||
|
|
||||||
export class CreateUser {
|
export class CreateUser {
|
||||||
@IsString()
|
@IsString()
|
||||||
@ -24,6 +24,8 @@ export class CreateUser {
|
|||||||
@IsInt()
|
@IsInt()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
groupId?: number[] | number
|
groupId?: number[] | number
|
||||||
|
@IsUUID("5")
|
||||||
|
uuid: string;
|
||||||
|
|
||||||
public async toUser(): Promise<User> {
|
public async toUser(): Promise<User> {
|
||||||
let newUser: User = new User();
|
let newUser: User = new User();
|
||||||
@ -39,12 +41,16 @@ export class CreateUser {
|
|||||||
throw new UserGroupNotFoundError();
|
throw new UserGroupNotFoundError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const new_uuid = uuid.v4()
|
||||||
|
|
||||||
newUser.email = this.email
|
newUser.email = this.email
|
||||||
newUser.username = this.username
|
newUser.username = this.username
|
||||||
newUser.firstname = this.firstname
|
newUser.firstname = this.firstname
|
||||||
newUser.middlename = this.middlename
|
newUser.middlename = this.middlename
|
||||||
newUser.lastname = this.lastname
|
newUser.lastname = this.lastname
|
||||||
|
newUser.uuid = new_uuid
|
||||||
// TODO: hash password here or in controller/ in User model via setter?
|
// TODO: hash password here or in controller/ in User model via setter?
|
||||||
|
this.password = await argon2.hash(this.password);
|
||||||
newUser.password = this.password
|
newUser.password = this.password
|
||||||
|
|
||||||
console.log(newUser)
|
console.log(newUser)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { Entity, Column, OneToMany, ManyToOne, PrimaryGeneratedColumn, Generated, Unique, JoinTable, ManyToMany } from "typeorm";
|
import { IsBoolean, IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString, IsUUID } from "class-validator";
|
||||||
import { IsBoolean, IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString, isUUID, } from "class-validator";
|
import { Column, Entity, JoinTable, ManyToMany, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
|
||||||
import { UserGroup } from './UserGroup';
|
|
||||||
import { Permission } from './Permission';
|
import { Permission } from './Permission';
|
||||||
import { UserAction } from './UserAction';
|
import { UserAction } from './UserAction';
|
||||||
|
import { UserGroup } from './UserGroup';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a admin user.
|
* Defines a admin user.
|
||||||
@ -20,9 +20,7 @@ export class User {
|
|||||||
/**
|
/**
|
||||||
* autogenerated uuid
|
* autogenerated uuid
|
||||||
*/
|
*/
|
||||||
@IsOptional()
|
@IsUUID("5")
|
||||||
@IsInt()
|
|
||||||
@Generated("uuid")
|
|
||||||
uuid: string;
|
uuid: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user