mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 07:47:07 +00:00
Send a request for new credentials at regular intervals.
Every five minutes, a message is sent via WebSocket to ask the server for a refreshed JWT token.
This commit is contained in:
@@ -7,6 +7,8 @@ import vueDebounce from 'vue-debounce'
|
|||||||
import { mapMutations } from 'vuex';
|
import { mapMutations } from 'vuex';
|
||||||
import { markdown, markdownInline } from './lib/markdown';
|
import { markdown, markdownInline } from './lib/markdown';
|
||||||
import { geometryAsString } from './lib/utils';
|
import { geometryAsString } from './lib/utils';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
|
|
||||||
@@ -14,7 +16,7 @@ Vue.use(vueDebounce);
|
|||||||
|
|
||||||
Vue.filter('markdown', markdown);
|
Vue.filter('markdown', markdown);
|
||||||
Vue.filter('markdownInline', markdownInline);
|
Vue.filter('markdownInline', markdownInline);
|
||||||
Vue.filter('position', (str, item, opts) =>
|
Vue.filter('position', (str, item, opts) =>
|
||||||
str
|
str
|
||||||
.replace(/@POS(ITION)?@/g, geometryAsString(item, opts) || "(position unknown)")
|
.replace(/@POS(ITION)?@/g, geometryAsString(item, opts) || "(position unknown)")
|
||||||
.replace(/@DMS@/g, geometryAsString(item, {...opts, dms:true}) || "(position unknown)")
|
.replace(/@DMS@/g, geometryAsString(item, {...opts, dms:true}) || "(position unknown)")
|
||||||
@@ -32,10 +34,16 @@ new Vue({
|
|||||||
user: null,
|
user: null,
|
||||||
|
|
||||||
wsUrl: "/ws",
|
wsUrl: "/ws",
|
||||||
ws: null
|
ws: null,
|
||||||
|
wsCredentialsCheckInterval: 300*1000, // ms
|
||||||
|
wsCredentialsCheckTimer: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
computed: {
|
||||||
|
...mapGetters(["jwt"])
|
||||||
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
markdown (value) {
|
markdown (value) {
|
||||||
@@ -85,6 +93,17 @@ new Vue({
|
|||||||
this.setServerConnectionState(false);
|
this.setServerConnectionState(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.wsCredentialsCheckTimer) {
|
||||||
|
clearInterval(this.wsCredentialsCheckTimer);
|
||||||
|
this.wsCredentialsCheckTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.wsCredentialsCheckTimer = setInterval( () => {
|
||||||
|
this.ws.send(JSON.stringify({
|
||||||
|
jwt: this.jwt
|
||||||
|
}));
|
||||||
|
}, this.wsCredentialsCheckInterval);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
...mapMutations(['setServerEvent', 'setServerConnectionState'])
|
...mapMutations(['setServerEvent', 'setServerConnectionState'])
|
||||||
|
|||||||
Reference in New Issue
Block a user