Skip to content

Commit

Permalink
fix: previously user settings are remained even after user sign out. …
Browse files Browse the repository at this point in the history
…It was occured by that Object.assign update DefaultUserConfig variable in nodejs side. Now copied object is passed to Object.assign to prevent default value is changed. (#4283)
  • Loading branch information
JinIgarashi authored Oct 18, 2024
1 parent 99b3274 commit 73b2bcc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/witty-knives-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"geohub": patch
---

fix: previously user settings are remained even after user sign out. It was occured by that Object.assign update DefaultUserConfig variable in nodejs side. Now copied object is passed to Object.assign to prevent default value is changed.
6 changes: 5 additions & 1 deletion sites/geohub/src/routes/api/settings/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const POST: RequestHandler = async ({ request, locals }) => {
export const GET: RequestHandler = async ({ locals }) => {
const session = await locals.auth();
if (!session) {
console.log(DefaultUserConfig);
return new Response(JSON.stringify(DefaultUserConfig), {});
}
const user_email = session.user?.email;
Expand All @@ -37,7 +38,10 @@ export const GET: RequestHandler = async ({ locals }) => {
// no settings found for this user in the database
return new Response(JSON.stringify(DefaultUserConfig), {});
} else {
const data: UserConfig = Object.assign(DefaultUserConfig, settings.settings as UserConfig);
const data: UserConfig = Object.assign(
JSON.parse(JSON.stringify(DefaultUserConfig)),
settings.settings as UserConfig
);
if (typeof data.DataPageIngestingJoinVectorTiles === 'string') {
data.DataPageIngestingJoinVectorTiles =
data.DataPageIngestingJoinVectorTiles === 'true' ? true : false;
Expand Down

0 comments on commit 73b2bcc

Please sign in to comment.