From 99d88c8ab0976124112665c4bdba37f32d950809 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Thu, 8 Oct 2020 12:44:21 +0200 Subject: [PATCH] fix: remove organization name in register form. --- server/src/api/controllers/Authentication.ts | 6 ++---- server/src/interfaces/Authentication.ts | 5 +++++ server/src/services/Authentication/index.ts | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/server/src/api/controllers/Authentication.ts b/server/src/api/controllers/Authentication.ts index e5d162333..e219e5a81 100644 --- a/server/src/api/controllers/Authentication.ts +++ b/server/src/api/controllers/Authentication.ts @@ -2,10 +2,9 @@ import { Request, Response, Router } from 'express'; import { check, ValidationChain } from 'express-validator'; import { Service, Inject } from 'typedi'; import BaseController from 'api/controllers/BaseController'; -import validateMiddleware from 'api/middleware/validateMiddleware'; import asyncMiddleware from 'api/middleware/asyncMiddleware'; import AuthenticationService from 'services/Authentication'; -import { IUserOTD, ISystemUser, IRegisterOTD } from 'interfaces'; +import { ILoginDTO, ISystemUser, IRegisterOTD } from 'interfaces'; import { ServiceError, ServiceErrors } from "exceptions"; @Service() @@ -61,7 +60,6 @@ export default class AuthenticationController extends BaseController{ */ get registerSchema(): ValidationChain[] { return [ - check('organization_name').exists().trim().escape(), check('first_name').exists().trim().escape(), check('last_name').exists().trim().escape(), check('email').exists().isEmail().trim().escape(), @@ -102,7 +100,7 @@ export default class AuthenticationController extends BaseController{ * @param {Response} res */ async login(req: Request, res: Response, next: Function): Response { - const userDTO: IUserOTD = this.matchedBodyData(req); + const userDTO: ILoginDTO = this.matchedBodyData(req); try { const { token, user, tenant } = await this.authService.signIn( diff --git a/server/src/interfaces/Authentication.ts b/server/src/interfaces/Authentication.ts index 375c800ac..be86dfdd3 100644 --- a/server/src/interfaces/Authentication.ts +++ b/server/src/interfaces/Authentication.ts @@ -9,6 +9,11 @@ export interface IRegisterDTO { organizationName: string, }; +export interface ILoginDTO { + crediential: string, + password: string, +}; + export interface IPasswordReset { id: number, email: string, diff --git a/server/src/services/Authentication/index.ts b/server/src/services/Authentication/index.ts index 171c90e6a..12ccab4ec 100644 --- a/server/src/services/Authentication/index.ts +++ b/server/src/services/Authentication/index.ts @@ -135,7 +135,7 @@ export default class AuthenticationService implements IAuthenticationService { const { systemUserRepository } = this.sysRepositories; const registeredUser = await systemUserRepository.create({ - ...omit(registerDTO, 'country', 'organizationName'), + ...omit(registerDTO, 'country'), active: true, password: hashedPassword, tenant_id: tenant.id,