From fe88d3e1507145753318f73d8af178e59cc882e9 Mon Sep 17 00:00:00 2001 From: tonyrewin Date: Fri, 9 Sep 2022 17:13:50 +0300 Subject: [PATCH] renew-session --- src/components/Nav/AuthModal.tsx | 4 ++-- src/stores/auth.ts | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/Nav/AuthModal.tsx b/src/components/Nav/AuthModal.tsx index 9f69d54e..eed0bd09 100644 --- a/src/components/Nav/AuthModal.tsx +++ b/src/components/Nav/AuthModal.tsx @@ -1,4 +1,4 @@ -import { isServer, Show } from 'solid-js/web' +import { Show } from 'solid-js/web' import Icon from './Icon' import { createEffect, createSignal, onMount } from 'solid-js' import './AuthModal.scss' @@ -6,7 +6,7 @@ import { Form } from 'solid-js-form' import { t } from '../../utils/intl' import { hideModal, useModalStore } from '../../stores/ui' import { useStore } from '@nanostores/solid' -import { session as sessionstore, signIn, updateSession } from '../../stores/auth' +import { session as sessionstore, signIn, renewSession } from '../../stores/auth' import { apiClient } from '../../utils/apiClient' import { useValidator } from '../../utils/validators' diff --git a/src/stores/auth.ts b/src/stores/auth.ts index dc4fd095..5f8f3685 100644 --- a/src/stores/auth.ts +++ b/src/stores/auth.ts @@ -50,3 +50,9 @@ export const signResetConfirm = action(session, 'signResetConfirm', async (store setToken(auth.token) store.set(auth) }) + +export const renewSession = action(session, 'renewSession', async (store) => { + const s = await apiClient.getSession() // token in header + setToken(s.token) + store.set(s) +})