From 940bc5fecfe6afa4a3ab50d0e141fc7affa2e686 Mon Sep 17 00:00:00 2001 From: Vladyslav Karpenko Date: Fri, 15 Dec 2023 19:55:05 +0200 Subject: [PATCH] Fix session auth/restore logic Problem: forbidden access to the logged endpoints after successful `auth/restore`. Closes: https://github.com/metarhia/Example/issues/238 --- application/api/auth/restore.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/application/api/auth/restore.js b/application/api/auth/restore.js index cf1fe759..abe0c691 100644 --- a/application/api/auth/restore.js +++ b/application/api/auth/restore.js @@ -4,6 +4,8 @@ const restored = context.client.restoreSession(token); if (restored) return { status: 'logged' }; const data = await api.auth.provider.readSession(token); - return { status: data ? 'logged' : 'not logged' }; + if (!data) return { status: 'not logged' }; + context.client.startSession(token, data); + return { status: 'logged' }; }, });