Compare commits

...

3 Commits

Author SHA1 Message Date
d803704eee UserNotFoundError
ref #12
2020-12-04 23:02:23 +01:00
a5b1804e19 Merge branch 'dev' into feature/12-jwt-creation 2020-12-04 22:51:57 +01:00
a7854fbe81 CreateUser - remove uuid from params
ref #11
2020-12-04 22:51:44 +01:00
2 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,5 @@
import { IsString } from 'class-validator'; import { IsString } from 'class-validator';
import { ForbiddenError, NotAcceptableError, UnauthorizedError } from 'routing-controllers'; import { ForbiddenError, NotAcceptableError, NotFoundError, UnauthorizedError } from 'routing-controllers';
/** /**
* Error to throw when a jwt is expired * Error to throw when a jwt is expired
@ -66,3 +66,14 @@ export class PasswordNeededError extends NotAcceptableError {
@IsString() @IsString()
message = "no password is provided - you need to provide it" message = "no password is provided - you need to provide it"
} }
/**
* Error to thow when no user could be found for provided credential
*/
export class UserNotFoundError extends NotFoundError {
@IsString()
name = "UserNotFoundError"
@IsString()
message = "no user could be found for provided credential"
}

View File

@ -1,5 +1,5 @@
import * as argon2 from "argon2"; import * as argon2 from "argon2";
import { IsEmail, IsOptional, IsPhoneNumber, IsString, IsUUID } from 'class-validator'; import { IsEmail, IsOptional, IsPhoneNumber, IsString } from 'class-validator';
import { getConnectionManager } from 'typeorm'; import { getConnectionManager } from 'typeorm';
import * as uuid from 'uuid'; import * as uuid from 'uuid';
import { UserGroupNotFoundError, UsernameOrEmailNeededError } from '../../errors/UserErrors'; import { UserGroupNotFoundError, UsernameOrEmailNeededError } from '../../errors/UserErrors';
@ -26,8 +26,6 @@ export class CreateUser {
email?: string; email?: string;
@IsOptional() @IsOptional()
groupId?: number[] | number groupId?: number[] | number
@IsUUID("4")
uuid: string;
public async toUser(): Promise<User> { public async toUser(): Promise<User> {
let newUser: User = new User(); let newUser: User = new User();