@@ -15,6 +15,7 @@ import { ApiBearerAuth, ApiBody, ApiOperation, ApiResponse, ApiTags } from '@nes
1515import { SkipThrottle } from '@nestjs/throttler' ;
1616import { UseCaseType } from '../../common/data-injection.tokens.js' ;
1717import { Timeout } from '../../decorators/timeout.decorator.js' ;
18+ import { FoundUserEmailCompaniesInfoDs } from '../../entities/company-info/application/data-structures/found-company-info.ds.js' ;
1819import { CompanyInfoEntity } from '../../entities/company-info/company-info.entity.js' ;
1920import { CreatedConnectionDTO } from '../../entities/connection/application/dto/created-connection.dto.js' ;
2021import { SaasUsualUserRegisterDS } from '../../entities/user/application/data-structures/usual-register-user.ds.js' ;
@@ -23,6 +24,7 @@ import { ExternalRegistrationProviderEnum } from '../../entities/user/enums/exte
2324import { UserEntity } from '../../entities/user/user.entity.js' ;
2425import { InTransactionEnum } from '../../enums/in-transaction.enum.js' ;
2526import { Messages } from '../../exceptions/text/messages.js' ;
27+ import { ValidationHelper } from '../../helpers/validators/validation-helper.js' ;
2628import { SentryInterceptor } from '../../interceptors/sentry.interceptor.js' ;
2729import { CreatedConnectionResponse , SuccessResponse } from './data-structures/common-responce.ds.js' ;
2830import { CreateConnectionForHostedDbDto } from './data-structures/create-connecttion-for-selfhosted-db.dto.js' ;
@@ -51,6 +53,7 @@ import {
5153 ISaaSGetCompanyInfoByUserId ,
5254 ISaaSGetUsersCountInCompany ,
5355 ISaasDemoRegisterUser ,
56+ ISaasGetUserEmailCompanies ,
5457 ISaasGetUsersInfosByEmail ,
5558 ISaasRegisterUser ,
5659 ISaasSAMLRegisterUser ,
@@ -79,6 +82,8 @@ export class SaasController {
7982 private readonly usualRegisterUserUseCase : ISaasRegisterUser ,
8083 @Inject ( UseCaseType . SAAS_USUAL_LOGIN_USER )
8184 private readonly usualLoginUserUseCase : ISaasUsualLoginUser ,
85+ @Inject ( UseCaseType . SAAS_GET_USER_EMAIL_COMPANIES )
86+ private readonly getUserEmailCompaniesUseCase : ISaasGetUserEmailCompanies ,
8287 @Inject ( UseCaseType . SAAS_DEMO_USER_REGISTRATION )
8388 private readonly demoRegisterUserUseCase : ISaasDemoRegisterUser ,
8489 @Inject ( UseCaseType . SAAS_LOGIN_USER_WITH_GOOGLE )
@@ -194,6 +199,19 @@ export class SaasController {
194199 ) ;
195200 }
196201
202+ @ApiOperation ( { summary : 'Get companies where a user with this email is registered' } )
203+ @ApiResponse ( {
204+ status : 200 ,
205+ description : 'Companies where a user with this email is registered.' ,
206+ type : FoundUserEmailCompaniesInfoDs ,
207+ isArray : true ,
208+ } )
209+ @Get ( 'user/email/:email/companies' )
210+ async getUserEmailCompanies ( @Param ( 'email' ) email : string ) : Promise < Array < FoundUserEmailCompaniesInfoDs > > {
211+ ValidationHelper . validateOrThrowHttpExceptionEmail ( email ) ;
212+ return await this . getUserEmailCompaniesUseCase . execute ( email ) ;
213+ }
214+
197215 @ApiOperation ( { summary : 'Register demo user register webhook' } )
198216 @ApiBody ( { type : SaasUsualUserRegisterDS } )
199217 @ApiResponse ( {
0 commit comments