From 32c76cd4d95553546cab983c223528d192e5462a Mon Sep 17 00:00:00 2001 From: Carlos Date: Fri, 20 Oct 2023 17:47:06 -0500 Subject: [PATCH] add multisigSession fetch --- src/routes/v1/multisigAuthenticationRouter.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/routes/v1/multisigAuthenticationRouter.ts b/src/routes/v1/multisigAuthenticationRouter.ts index c2c217c..19e5495 100644 --- a/src/routes/v1/multisigAuthenticationRouter.ts +++ b/src/routes/v1/multisigAuthenticationRouter.ts @@ -2,6 +2,7 @@ import express, { Request, Response } from 'express'; import { errorMessagesEnum } from '../../utils/errorMessages'; import { logger } from '../../utils/logger'; import { MultisigAuthenticationController } from '@/src/controllers/v1/multisigAuthenticationController'; +import { findNonExpiredMultisigSessions } from '@/src/repositories/multisigSessionRepository'; export const multisigAuthenticationRouter = express.Router(); const multisigAuthenticationController = new MultisigAuthenticationController(); @@ -31,3 +32,26 @@ multisigAuthenticationRouter.post( } }, ); + +multisigAuthenticationRouter.get( + '/multisigAuthentication', + async (req: Request, res: Response, next) => { + try { + const { safeAddress, network } = req.body; + if (!safeAddress || !network) { + res.status(422).json({ message: errorMessagesEnum.MISSING_LOGIN_DATA }); + return; + } + + const multisigSession = await findNonExpiredMultisigSessions( + safeAddress, + network, + ); + + res.send({ active: multisigSession ? true : false }); + } catch (e) { + logger.error('multisigAuthenticationController() error', e); + next(e); + } + }, +);