Skip to content

Commit

Permalink
Merge pull request #689 from openstad/fix/save-auth-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
rudivanhierden authored Nov 19, 2024
2 parents 6574d97 + da67957 commit ee4dabf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/api-server/src/adapter/openstad/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ service.updateClient = async function({ authConfig, project }) {
canCreateNewUsers: project.config.users?.canCreateNewUsers
},
styling: {
logo: authConfig?.config?.styling?.logo || project.config.styling?.logo,
favicon: authConfig?.config?.styling?.favicon || project.config.styling?.favicon,
logo: authConfig?.config?.styling?.logo || client?.config?.styling?.logo || project.config.styling?.logo,
favicon: authConfig?.config?.styling?.favicon || client?.config?.styling?.favicon || project.config.styling?.favicon,
inlineCSS: project.config.styling?.inlineCSS,
displayClientName: project.config.styling?.displayClientName,
},
Expand Down
8 changes: 5 additions & 3 deletions apps/api-server/src/routes/api/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,13 +599,15 @@ router.route('/:projectId') //(\\d+)
if (!hasRole( req.user, 'admin')) return next();
try {
let providers = await authSettings.providers({ project });
const configData = req.body.config?.auth?.provider?.openstad?.config || {};

for (let provider of providers) {
let authData = req.body.config?.auth?.provider?.[provider];
if (!authData) continue;
if ( Object.keys(configData).length === 0 ) continue;

let authConfig = await authSettings.config({ project, useAuth: provider });
let adapter = await authSettings.adapter({ authConfig });
if (adapter.service.updateClient) {
let merged = merge.recursive({}, authConfig, req.body.config?.auth?.provider?.[authConfig.provider])
let merged = merge.recursive({}, authConfig, {config: configData});
await adapter.service.updateClient({ authConfig: merged, project });
delete req.body.config?.auth?.provider?.[authConfig.provider]?.authTypes;
delete req.body.config?.auth?.provider?.[authConfig.provider]?.twoFactorRoles;
Expand Down

0 comments on commit ee4dabf

Please sign in to comment.