Compare commits

..

No commits in common. "f1629440feae3a49ab17ec7d29b709ff392d6988" and "8292ec3a1ee304552ba2d4aefff4a90e9a3bc5c4" have entirely different histories.

4 changed files with 13 additions and 24 deletions

View File

@ -7,11 +7,7 @@
},
"prettier.enable": false,
"[typescript]": {
"editor.defaultFormatter": "vscode.typescript-language-features",
"editor.codeActionsOnSave": {
"source.organizeImports": true,
"source.fixAll": true
}
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"javascript.preferences.quoteStyle": "single",
"javascript.preferences.importModuleSpecifierEnding": "minimal",

View File

@ -22,7 +22,6 @@
],
"license": "CC-BY-NC-SA-4.0",
"dependencies": {
"argon2": "^0.27.0",
"body-parser": "^1.19.0",
"class-transformer": "^0.3.1",
"class-validator": "^0.12.2",
@ -40,8 +39,7 @@
"routing-controllers-openapi": "^2.1.0",
"swagger-ui-express": "^4.1.5",
"typeorm": "^0.2.29",
"typeorm-routing-controllers-extensions": "^0.2.0",
"uuid": "^8.3.1"
"typeorm-routing-controllers-extensions": "^0.2.0"
},
"devDependencies": {
"@types/cors": "^2.8.8",
@ -51,7 +49,6 @@
"@types/multer": "^1.4.4",
"@types/node": "^14.14.9",
"@types/swagger-ui-express": "^4.1.2",
"@types/uuid": "^8.3.0",
"dotenv-safe": "^8.2.0",
"nodemon": "^2.0.6",
"sqlite3": "^5.0.0",
@ -64,4 +61,4 @@
"build": "tsc",
"docs": "typedoc --out docs src"
}
}
}

View File

@ -1,8 +1,8 @@
import * as argon2 from "argon2";
import { IsInt, IsOptional, IsPhoneNumber, IsString, IsUUID } from 'class-validator';
import * as uuid from 'uuid';
import { UserGroupNotFoundError, UsernameOrEmailNeededError } from '../errors/CreateUserErrors';
import { IsInt, IsOptional, IsPhoneNumber, IsString } from 'class-validator';
import { User } from '../models/User';
import { getConnectionManager } from 'typeorm';
import { UserGroupNotFoundError, UsernameOrEmailNeededError } from '../errors/CreateUserErrors';
import { UserGroup } from './UserGroup';
export class CreateUser {
@IsString()
@ -24,8 +24,6 @@ export class CreateUser {
@IsInt()
@IsOptional()
groupId?: number[] | number
@IsUUID("5")
uuid: string;
public async toUser(): Promise<User> {
let newUser: User = new User();
@ -41,16 +39,12 @@ export class CreateUser {
throw new UserGroupNotFoundError();
}
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
// TODO: hash password here or in controller/ in User model via setter?
this.password = await argon2.hash(this.password);
newUser.password = this.password
console.log(newUser)

View File

@ -1,8 +1,8 @@
import { IsBoolean, IsEmail, IsInt, IsNotEmpty, IsOptional, IsPhoneNumber, IsString, IsUUID } from "class-validator";
import { Column, Entity, JoinTable, ManyToMany, ManyToOne, OneToMany, PrimaryGeneratedColumn } from "typeorm";
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 { UserGroup } from './UserGroup';
import { Permission } from './Permission';
import { UserAction } from './UserAction';
import { UserGroup } from './UserGroup';
/**
* Defines a admin user.
@ -20,7 +20,9 @@ export class User {
/**
* autogenerated uuid
*/
@IsUUID("5")
@IsOptional()
@IsInt()
@Generated("uuid")
uuid: string;
/**