Compare commits

..

No commits in common. "d2c826c7c9a8b79ff5ab6268865a26791b36c2c2" and "684e7c4ddbb10e88ead1d33e93f97fc7dcb0db25" have entirely different histories.

4 changed files with 7 additions and 76 deletions

View File

@ -1,53 +0,0 @@
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()
firstname: string;
@IsString()
middlename?: string;
@IsOptional()
@IsString()
username?: string;
@IsPhoneNumber("ZZ")
@IsOptional()
phone?: string;
@IsString()
password: string;
@IsString()
lastname: string;
@IsString()
email?: string;
@IsInt()
@IsOptional()
groupId?: number[] | number
public async toUser(): Promise<User> {
let newUser: User = new User();
if (this.email === undefined && this.username === undefined) {
throw new UsernameOrEmailNeededError();
}
if (this.groupId) {
// TODO: link user groups
// newUser.groups = await getConnectionManager().get().getRepository(UserGroup).findOne({ id: this.teamId });
} else {
throw new UserGroupNotFoundError();
}
newUser.email = this.email
newUser.username = this.username
newUser.firstname = this.firstname
newUser.middlename = this.middlename
newUser.lastname = this.lastname
// TODO: hash password here or in controller/ in User model via setter?
newUser.password = this.password
console.log(newUser)
return newUser;
}
}

View File

@ -1,7 +1,6 @@
import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, OneToMany } from "typeorm";
import {
IsBoolean,
IsEAN,
IsInt,
IsNotEmpty,
IsOptional,
@ -33,12 +32,12 @@ export class RunnerCard {
/**
* The card's code.
* This has to be able to being converted to something barcode compatible.
* could theoretically be autogenerated
* Probably gonna be autogenerated.
*/
@Column()
@IsEAN()
@IsString()
@IsNotEmpty()
//TODO: Generate this
code: string;
/**

View File

@ -42,12 +42,4 @@ export abstract class Scan {
@Column()
@IsBoolean()
valid: boolean = true;
/**
* seconds since last scan
*/
@IsInt()
@IsOptional()
secondsSinceLastScan: number;
}

View File

@ -1,5 +1,5 @@
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, IsString, isUUID, } from "class-validator";
import { UserGroup } from './UserGroup';
import { Permission } from './Permission';
import { UserAction } from './UserAction';
@ -31,13 +31,6 @@ export class User {
@IsEmail()
email: string;
/**
* user phone
*/
@IsPhoneNumber("ZZ")
@IsOptional()
phone: string;
/**
* username
*/