Изменения механизма ограничения доступа
This commit is contained in:
@@ -60,10 +60,21 @@ const componentOptions = {
|
||||
settings() {
|
||||
this.loadSettings();
|
||||
},
|
||||
modelValue(newValue) {
|
||||
this.accessGranted = newValue;
|
||||
},
|
||||
accessGranted(newValue) {
|
||||
this.$emit('update:modelValue', newValue);
|
||||
}
|
||||
},
|
||||
};
|
||||
class Api {
|
||||
_options = componentOptions;
|
||||
_props = {
|
||||
modelValue: Boolean,
|
||||
};
|
||||
accessGranted = false;
|
||||
|
||||
busyDialogVisible = false;
|
||||
mainMessage = '';
|
||||
jobMessage = '';
|
||||
@@ -123,7 +134,13 @@ class Api {
|
||||
});
|
||||
|
||||
if (result && result.value) {
|
||||
const accessToken = utils.toHex(cryptoUtils.sha256(result.value));
|
||||
//получим свежую соль
|
||||
const response = await wsc.message(await wsc.send({}), 10);
|
||||
let salt = '';
|
||||
if (response && response.error == 'need_access_token' && response.salt)
|
||||
salt = response.salt;
|
||||
|
||||
const accessToken = utils.toHex(cryptoUtils.sha256(result.value + salt));
|
||||
this.commit('setSettings', {accessToken});
|
||||
}
|
||||
} finally {
|
||||
@@ -192,10 +209,13 @@ class Api {
|
||||
const response = await wsc.message(await wsc.send(params), timeoutSecs);
|
||||
|
||||
if (response && response.error == 'need_access_token') {
|
||||
this.accessGranted = false;
|
||||
await this.showPasswordDialog();
|
||||
} else if (response && response.error == 'server_busy') {
|
||||
this.accessGranted = true;
|
||||
await this.showBusyDialog();
|
||||
} else {
|
||||
this.accessGranted = true;
|
||||
if (response.error) {
|
||||
throw new Error(response.error);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<div class="fit row">
|
||||
<Api ref="api" />
|
||||
<Api ref="api" v-model="accessGranted" />
|
||||
<Notify ref="notify" />
|
||||
<StdDialog ref="stdDialog" />
|
||||
|
||||
<router-view v-slot="{ Component }">
|
||||
<router-view v-if="accessGranted" v-slot="{ Component }">
|
||||
<keep-alive>
|
||||
<component :is="Component" class="col" />
|
||||
</keep-alive>
|
||||
@@ -37,6 +37,7 @@ const componentOptions = {
|
||||
};
|
||||
class App {
|
||||
_options = componentOptions;
|
||||
accessGranted = false;
|
||||
|
||||
created() {
|
||||
this.commit = this.$store.commit;
|
||||
|
||||
Reference in New Issue
Block a user