Merge pull request 'Session refresh on login' (#55) from session-refresh-on-login into main
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: mentorenwahl/mentorenwahl#55
This commit is contained in:
Dominic Grimm 2022-02-13 11:42:27 +00:00
commit c07cef18da
3 changed files with 6 additions and 3 deletions

View file

@ -13,7 +13,7 @@ declare namespace App {
interface Platform {}
interface Session {
user: Locals.user;
user: Locals["user"];
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface

View file

@ -1,5 +1,6 @@
<script lang="ts">
import { initClient } from "@urql/svelte";
import { session } from "$app/stores";
initClient({

View file

@ -3,8 +3,9 @@
import * as validators from "svelte-forms/validators";
import { setCookie, removeCookie } from "typescript-cookie";
import { operationStore, mutation, gql } from "@urql/svelte";
import { goto } from "$app/navigation";
import { session } from "$app/stores";
import { goto } from "$app/navigation";
import * as cookieNames from "$lib/cookieNames";
import type { LoginPayload } from "$lib/graphql";
@ -43,7 +44,8 @@
if ($loginStore.error) {
removeCookie(cookieNames.TOKEN);
} else {
setCookie(cookieNames.TOKEN, $loginStore.data.login.token, {
$session.user.token = $loginStore.data.login.token;
setCookie(cookieNames.TOKEN, $session.user.token, {
expires: 1,
});
goto("/");