From d9c76b8cb43e252b010effb0899bb67d969a1c07 Mon Sep 17 00:00:00 2001 From: fcaps Date: Fri, 1 Dec 2023 17:35:44 +0100 Subject: [PATCH] fixes --- src/backend/routes/views/account/post/report.js | 3 ++- src/backend/security/bootPassport.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/routes/views/account/post/report.js b/src/backend/routes/views/account/post/report.js index bf2af30b..0eb05d3b 100644 --- a/src/backend/routes/views/account/post/report.js +++ b/src/backend/routes/views/account/post/report.js @@ -111,9 +111,10 @@ exports = module.exports = [ }) if (resp.status !== 201) { + const apiError = JSON.parse(resp.data) req.query.flash = Buffer.from(JSON.stringify({ class: 'alert-danger', - messages: { errors: [{ msg: 'Error while submitting the report form' }] }, + messages: { errors: [{ msg: 'Error while submitting the report form' }, { msg: apiError.errors?.[0]?.detail || 'unknown api error' }] }, type: 'Error!' })).toString('base64') diff --git a/src/backend/security/bootPassport.js b/src/backend/security/bootPassport.js index ae9b96e6..1dd12e81 100644 --- a/src/backend/security/bootPassport.js +++ b/src/backend/security/bootPassport.js @@ -3,6 +3,7 @@ const OidcStrategy = require('passport-openidconnect') const refresh = require('passport-oauth2-refresh') const { JavaApiClientFactory } = require('../services/JavaApiClientFactory') const { UserRepository } = require('../services/UserRepository') +const { UserService } = require('../services/UserService') module.exports.bootPassport = (expressApp, appConfig) => { expressApp.use(passport.initialize()) @@ -27,7 +28,7 @@ module.exports.bootPassport = (expressApp, appConfig) => { refreshToken } - const apiClient = JavaApiClientFactory.createInstance(appConfig.apiUrl, oAuthPassport) + const apiClient = JavaApiClientFactory.createInstance(new UserService(), appConfig.apiUrl, oAuthPassport) const userRepository = new UserRepository(apiClient) userRepository.fetchUser(oAuthPassport).then(user => {