From c75add205860fc8e567957443dc583a4b4a45e72 Mon Sep 17 00:00:00 2001 From: dswbx Date: Thu, 21 Nov 2024 08:30:29 +0100 Subject: [PATCH] fix auth test --- app/__test__/modules/AppAuth.spec.ts | 2 +- app/src/auth/AppAuth.ts | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/__test__/modules/AppAuth.spec.ts b/app/__test__/modules/AppAuth.spec.ts index 0dd3018..7861fc6 100644 --- a/app/__test__/modules/AppAuth.spec.ts +++ b/app/__test__/modules/AppAuth.spec.ts @@ -19,7 +19,7 @@ describe("AppAuth", () => { await auth.build(); const config = auth.toJSON(); - expect(config.jwt).toBeUndefined(); + expect(config.jwt.secret).toBeUndefined(); expect(config.strategies.password.config).toBeUndefined(); }); diff --git a/app/src/auth/AppAuth.ts b/app/src/auth/AppAuth.ts index 73bb829..a829c8d 100644 --- a/app/src/auth/AppAuth.ts +++ b/app/src/auth/AppAuth.ts @@ -1,6 +1,6 @@ import { type AuthAction, Authenticator, type ProfileExchange, Role, type Strategy } from "auth"; import { Exception } from "core"; -import { Const, StringRecord, Type, transformObject } from "core/utils"; +import { transformObject } from "core/utils"; import { type Entity, EntityIndex, @@ -263,7 +263,17 @@ export class AppAuth extends Module { return this.configDefault; } - // fixes freezed config object - return mergeWith({ ...this.config }, this.authenticator.toJSON(secrets)); + const obj = { + ...this.config, + ...this.authenticator.toJSON(secrets) + }; + + return { + ...obj, + jwt: { + ...obj.jwt, + fields: this.config.jwt.fields + } + }; } }