Compare commits

..

No commits in common. "e97c5c3b7e781a7638c91bfaef83061a94b35d5f" and "19887c8f96ea6b26fd5c156c99f4b6147ac6be5f" have entirely different histories.

5 changed files with 6 additions and 41 deletions

View File

@ -2,20 +2,8 @@
All notable changes to this project will be documented in this file. Dates are displayed in UTC. All notable changes to this project will be documented in this file. Dates are displayed in UTC.
#### [0.1.2](https://git.odit.services/lfk/frontend/compare/0.1.2-1...0.1.2)
- Merge commit '2a37dfafa426e070aa136d171a1a01aa7f609d18' into dev [`#29`](https://git.odit.services/lfk/frontend/issues/29)
- Merge commit '5810b4ec4396ad650d90493fb48e2a8320865b42' into dev [`#4`](https://git.odit.services/lfk/frontend/issues/4)
- 🔒 added basic manual refresh every 4mins [`d92c6c0`](https://git.odit.services/lfk/frontend/commit/d92c6c0de9d6b72027b8aa27b22e3dc7b5116af1)
- dropped redundant console.log [`2a37dfa`](https://git.odit.services/lfk/frontend/commit/2a37dfafa426e070aa136d171a1a01aa7f609d18)
- 💾 save new auth data to localstorage [`2cbb431`](https://git.odit.services/lfk/frontend/commit/2cbb431acc0fe1aa333ddedb76510486a5fcf191)
- new license file version [CI SKIP] [`519ba79`](https://git.odit.services/lfk/frontend/commit/519ba79e1d5d97e2f59f769ef952a649481b55c0)
#### [0.1.2-1](https://git.odit.services/lfk/frontend/compare/0.1.2-0...0.1.2-1) #### [0.1.2-1](https://git.odit.services/lfk/frontend/compare/0.1.2-0...0.1.2-1)
> 10 January 2021
- 🚀RELEASE v0.1.2-1 [`5810b4e`](https://git.odit.services/lfk/frontend/commit/5810b4ec4396ad650d90493fb48e2a8320865b42)
- 🧪 modified auto-changelog to commit CHANGELOG.md [`52aa996`](https://git.odit.services/lfk/frontend/commit/52aa99681bb02472e0433cb32b89dde814cd9467) - 🧪 modified auto-changelog to commit CHANGELOG.md [`52aa996`](https://git.odit.services/lfk/frontend/commit/52aa99681bb02472e0433cb32b89dde814cd9467)
#### [0.1.2-0](https://git.odit.services/lfk/frontend/compare/0.1.1...0.1.2-0) #### [0.1.2-0](https://git.odit.services/lfk/frontend/compare/0.1.1...0.1.2-0)

View File

@ -1,6 +1,6 @@
{ {
"name": "@odit/lfk-frontend", "name": "@odit/lfk-frontend",
"version": "0.1.2", "version": "0.1.2-1",
"scripts": { "scripts": {
"i18n-order": "node order.js", "i18n-order": "node order.js",
"dev": "snowpack dev", "dev": "snowpack dev",

File diff suppressed because one or more lines are too long

View File

@ -17,7 +17,7 @@
is_blocked_by_autologin = true; is_blocked_by_autologin = true;
OpenAPI.TOKEN = value.access_token; OpenAPI.TOKEN = value.access_token;
const jwtinfo = JSON.parse(atob(OpenAPI.TOKEN.split(".")[1])); const jwtinfo = JSON.parse(atob(OpenAPI.TOKEN.split(".")[1]));
store.login(value, jwtinfo); store.login(value.access_token, jwtinfo);
Toastify({ Toastify({
text: $_("welcome_wavinghand"), text: $_("welcome_wavinghand"),
duration: 500, duration: 500,

View File

@ -1,16 +1,12 @@
import { writable } from 'svelte/store'; import { writable } from 'svelte/store';
import { OpenAPI, AuthService } from '@odit/lfk-client-js';
import localForage from 'localforage';
export let users = writable([]); export let users = writable([]);
export let tracks = writable([]); export let tracks = writable([]);
const store = () => { const store = () => {
const state = { const state = {
auth: undefined,
access_token: undefined, access_token: undefined,
jwtinfo: undefined, jwtinfo: undefined,
isLoggedIn: false, isLoggedIn: false
refreshInterval: undefined
}; };
const { subscribe, set, update } = writable(state); const { subscribe, set, update } = writable(state);
@ -22,36 +18,17 @@ const store = () => {
return state; return state;
}); });
}, },
refreshAuth() { login(access_token, jwtinfo) {
console.log('refreshing auth');
AuthService.authControllerRefresh({ token: state.auth.refresh_token }).then((auth) => {
console.log('got new auth');
OpenAPI.TOKEN = auth.access_token;
localForage.setItem('logindata', auth);
});
},
login(auth, jwtinfo) {
update((state) => { update((state) => {
state.auth = auth; state.access_token = access_token;
state.access_token = auth.access_token;
state.jwtinfo = jwtinfo; state.jwtinfo = jwtinfo;
state.isLoggedIn = true; state.isLoggedIn = true;
//
state.refreshInterval = setInterval(() => {
this.refreshAuth();
// 4min
}, 4 * 60000);
//
return state; return state;
}); });
}, },
logout() { logout() {
update((state) => { update((state) => {
state.isLoggedIn = false; state.isLoggedIn = false;
//
clearInterval(state.refreshInterval);
state.refreshInterval = undefined;
//
return state; return state;
}); });
} }