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:
D. Berge
2024-05-01 10:19:00 +02:00
parent 76a90df768
commit c6b99563d9

View File

@@ -7,6 +7,8 @@ import vueDebounce from 'vue-debounce'
import { mapMutations } from 'vuex';
import { markdown, markdownInline } from './lib/markdown';
import { geometryAsString } from './lib/utils';
import { mapGetters } from 'vuex';
Vue.config.productionTip = false
@@ -32,10 +34,16 @@ new Vue({
user: null,
wsUrl: "/ws",
ws: null
ws: null,
wsCredentialsCheckInterval: 300*1000, // ms
wsCredentialsCheckTimer: null
}
},
computed: {
...mapGetters(["jwt"])
},
methods: {
markdown (value) {
@@ -85,6 +93,17 @@ new Vue({
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'])