diff --git a/package-lock.json b/package-lock.json index d264e12..4911a72 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,19 @@ { "name": "@apihub24/token-authentication", - "version": "1.0.4", + "version": "1.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@apihub24/token-authentication", - "version": "1.0.4", + "version": "1.0.5", "license": "MIT", "dependencies": { "@apihub24/repository": "^1.0.3", "@nestjs/common": "^11.1.6", "@nestjs/config": "^4.0.2", "@nestjs/core": "^11.1.6", + "class-transformer": "^0.5.1", "class-validator": "^0.14.2" }, "devDependencies": { @@ -2022,6 +2023,12 @@ "dev": true, "license": "MIT" }, + "node_modules/class-transformer": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/class-transformer/-/class-transformer-0.5.1.tgz", + "integrity": "sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==", + "license": "MIT" + }, "node_modules/class-validator": { "version": "0.14.2", "resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.14.2.tgz", diff --git a/package.json b/package.json index a17e31d..642b53c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@apihub24/token-authentication", - "version": "1.0.4", + "version": "1.0.5", "description": "", "main": "dist/index.js", "types": "./dist/index.d.ts", @@ -16,7 +16,8 @@ "@nestjs/config": "^4.0.2", "@nestjs/core": "^11.1.6", "@apihub24/repository": "^1.0.3", - "class-validator": "^0.14.2" + "class-validator": "^0.14.2", + "class-transformer": "^0.5.1" }, "devDependencies": { "rimraf": "^6.0.1", diff --git a/src/services/account.factory.service.ts b/src/services/account.factory.service.ts index d0ae877..a29b790 100644 --- a/src/services/account.factory.service.ts +++ b/src/services/account.factory.service.ts @@ -5,6 +5,8 @@ import * as passwordService from "../contracts/services/password.service"; import { IRegistration } from "../contracts/models/registration"; import { IAccount } from "../contracts/models/account"; import { Account } from "../models/account"; +import { plainToClass } from "class-transformer"; +import { Registration } from "../models/registration"; @Injectable() export class AccountFactoryService { @@ -16,7 +18,9 @@ export class AccountFactoryService { ) {} async createFromRegistration(registration: IRegistration): Promise { - let validationErrors = await validate(registration); + let validationErrors = await validate( + plainToClass(Registration, registration) + ); if (validationErrors?.length) { throw new Error(validationErrors[0].toString()); }