File tree Expand file tree Collapse file tree
backend/src/entities/connection Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ async function checkConnectionToken(connectionToken) {
115115 console . info ( '-> response.data' , response . data ) ;
116116 return false ;
117117 }
118- const result = response . data === true ;
118+ const result = ! ! response . data . isValid ;
119119 if ( result ) {
120120 tokenCacheResult . set ( connectionToken , true ) ;
121121 }
Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ import { FoundOneConnectionDs } from './application/data-structures/found-one-co
7777import { FoundGroupResponseDto } from '../group/dto/found-group-response.dto.js' ;
7878import { FoundUserGroupsInConnectionDTO } from './application/dto/found-user-groups-in-connection.dto.js' ;
7979import { SuccessResponse } from '../../microservices/saas-microservice/data-structures/common-responce.ds.js' ;
80+ import { TokenValidationResult } from './use-cases/validate-connection-token.use.case.js' ;
8081
8182@UseInterceptors ( SentryInterceptor )
8283@Controller ( )
@@ -614,9 +615,9 @@ export class ConnectionController {
614615 type : Boolean ,
615616 } )
616617 @Get ( '/connection/token/' )
617- async validateConnectionAgentToken ( @Query ( 'token' ) token : string ) : Promise < boolean > {
618+ async validateConnectionAgentToken ( @Query ( 'token' ) token : string ) : Promise < TokenValidationResult > {
618619 if ( ! token || typeof token !== 'string' || token . length === 0 ) {
619- return false ;
620+ return { isValid : false } ;
620621 }
621622 return await this . validateConnectionTokenUseCase . execute ( token , InTransactionEnum . OFF ) ;
622623 }
@@ -656,7 +657,7 @@ export class ConnectionController {
656657 if ( connectionData . type === ConnectionTypesEnum . dynamodb ) {
657658 return errors ;
658659 }
659-
660+
660661 if ( ! connectionData . database ) errors . push ( Messages . DATABASE_MISSING ) ;
661662 if ( process . env . NODE_ENV !== 'test' && ! connectionData . ssh ) {
662663 if ( ! this . isMongoHost ( connectionData . host ) ) {
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import { FoundOneConnectionDs } from '../application/data-structures/found-one-c
2020import { FoundGroupResponseDto } from '../../group/dto/found-group-response.dto.js' ;
2121import { FoundUserGroupsInConnectionDTO } from '../application/dto/found-user-groups-in-connection.dto.js' ;
2222import { SuccessResponse } from '../../../microservices/saas-microservice/data-structures/common-responce.ds.js' ;
23+ import { TokenValidationResult } from './validate-connection-token.use.case.js' ;
2324
2425export interface IFindConnections {
2526 execute ( user : CreateUserDs , inTransaction : InTransactionEnum ) : Promise < FoundConnectionsDs > ;
@@ -83,7 +84,7 @@ export interface IRestoreConnection {
8384}
8485
8586export interface IValidateConnectionToken {
86- execute ( token : string , inTransaction : InTransactionEnum ) : Promise < boolean > ;
87+ execute ( token : string , inTransaction : InTransactionEnum ) : Promise < TokenValidationResult > ;
8788}
8889
8990export interface IRefreshConnectionAgentToken {
Original file line number Diff line number Diff line change @@ -5,9 +5,12 @@ import { BaseType } from '../../../common/data-injection.tokens.js';
55import { Encryptor } from '../../../helpers/encryption/encryptor.js' ;
66import { IValidateConnectionToken } from './use-cases.interfaces.js' ;
77
8+ export type TokenValidationResult = {
9+ isValid : boolean ;
10+ } ;
811@Injectable ( )
912export class ValidateConnectionTokenUseCase
10- extends AbstractUseCase < string , boolean >
13+ extends AbstractUseCase < string , TokenValidationResult >
1114 implements IValidateConnectionToken
1215{
1316 constructor (
@@ -17,9 +20,9 @@ export class ValidateConnectionTokenUseCase
1720 super ( ) ;
1821 }
1922
20- protected async implementation ( connectionToken : string ) : Promise < boolean > {
23+ protected async implementation ( connectionToken : string ) : Promise < TokenValidationResult > {
2124 connectionToken = Encryptor . hashDataHMAC ( connectionToken ) ;
2225 const foundConnection = await this . _dbContext . connectionRepository . findOneAgentConnectionByToken ( connectionToken ) ;
23- return ! ! foundConnection ;
26+ return { isValid : ! ! foundConnection } ;
2427 }
2528}
You can’t perform that action at this time.
0 commit comments