💾 login state preserve (localstorage) + ℹ JWT payload parsing

ref #8
This commit is contained in:
2020-12-30 19:55:57 +01:00
parent 51c18e03a7
commit 13ccb56354
4 changed files with 38 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ import { writable } from 'svelte/store';
const store = () => {
const state = {
access_token: undefined,
jwtinfo: undefined,
isLoggedIn: false
};
@@ -16,10 +17,10 @@ const store = () => {
return state;
});
},
login(access_token) {
login(access_token, jwtinfo) {
update((state) => {
state.access_token = access_token;
state.jwtinfo = jwtinfo;
state.isLoggedIn = true;
console.log('login performed');
return state;
@@ -37,6 +38,7 @@ const store = () => {
subscribe,
set,
update,
state,
...methods
};
};