This commit is contained in:
2021-03-12 01:38:29 +00:00
parent 2913c32eeb
commit bf3607c737
5 changed files with 74 additions and 52 deletions

View File

@@ -13,6 +13,8 @@ export function processLogin(authResponse, loggedInWithKnownPassword) {
return reject();
}
//is token present?
if (!authResponse || !authResponse.token) {
window.$gz.store.commit(

View File

@@ -162,6 +162,9 @@ export default new Vuex.Store({
},
setNewNotificationCount(state, data) {
state.newNotificationCount = data;
},
setTfaEnabled(state, data) {
state.tfaEnabled = data;
}
},
actions: {}

View File

@@ -2,12 +2,26 @@
<v-row v-if="formState.ready">
<v-col>
<v-form ref="form">
<button
type="submit"
disabled
style="display: none"
aria-hidden="true"
></button>
<v-row>
<gz-error :error-box-message="formState.errorBoxMessage"></gz-error>
<template v-if="tfaEnabled">
<v-btn color="accent" text @click="disable()">{{
$ay.t("AuthDisableTwoFactor")
}}</v-btn>
<v-col cols="12">
<v-card class="mx-auto my-12" max-width="600">
<v-card-title>{{ $ay.t("AuthConnectAppTitle") }}</v-card-title>
<v-card-text>
<v-btn color="accent" @click="disable()">{{
$ay.t("AuthDisableTwoFactor")
}}</v-btn>
</v-card-text>
</v-card>
</v-col>
</template>
<template v-else>
<v-col cols="12">
@@ -171,6 +185,7 @@ export default {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
window.$gz.store.commit("setTfaEnabled", false);
await window.$gz.dialog.displayLTModalNotificationMessage(
"AuthTwoFactorDisabled"
);
@@ -205,6 +220,7 @@ export default {
window.$gz.form.setErrorBoxErrors(vm);
} else {
if (res.data.ok == true) {
window.$gz.store.commit("setTfaEnabled", true);
//all ok, 2fa enabled
await window.$gz.dialog.displayLTModalNotificationMessage(
"AuthConnectCompleted"

View File

@@ -407,44 +407,17 @@ export default {
// throw new Error(res.error);
throw new Error(window.$gz.errorHandler.errorToString(res, vm));
}
await processLogin(res.data, loggedInWithKnownPassword);
//check if support and updates has expired and is paid for license and show warning if so
if (
vm.$store.state.globalSettings.maintenanceExpired &&
(vm.$store.state.globalSettings.licenseStatus == 3 ||
vm.$store.state.globalSettings.licenseStatus == 4)
) {
(async function() {
await window.$gz.dialog.displayLTModalNotificationMessage(
"MaintenanceExpiredNote",
"MaintenanceExpired",
"error",
"https://www.ayanova.com/subscriptionexpired.htm"
);
})();
//check for 2fa enabled, if so then need to do one more step before process login can be called
if (res.data.tfa) {
//prompt for 2fa
//send 2fa code to server if ok, then proceed as normal
await this.step2(res, loggedInWithKnownPassword);
}
let toPath = vm.$route.params.topath; //set in app.vue::mounted
if (toPath != undefined) {
//check if it's an open report link and if so
//trigger that to open in a new window and continue on to normal home page
if (toPath.startsWith("/viewreport")) {
(async function() {
//open report links have a query string /viewreport?oid=[objectid]&rid=[reportid]
let searchParams = new URLSearchParams(vm.$route.params.search);
let objectId = parseInt(searchParams.get("oid"));
let reportId = parseInt(searchParams.get("rid"));
await window.$gz.api.renderReport(objectId, reportId); //objectid,reportid
})();
vm.$router.push(vm.$store.state.homePage);
} else {
//otherwise open the url indicated
vm.$router.push(vm.$route.params.topath);
}
} else {
vm.$router.push(vm.$store.state.homePage);
}
await this.step2(res, loggedInWithKnownPassword);
} catch (error) {
//bad creds?
if (
@@ -479,6 +452,47 @@ export default {
}
}
}
},
async step2(res, loggedInWithKnownPassword) {
let vm = this;
await processLogin(res.data, loggedInWithKnownPassword);
//check if support and updates has expired and is paid for license and show warning if so
if (
vm.$store.state.globalSettings.maintenanceExpired &&
(vm.$store.state.globalSettings.licenseStatus == 3 ||
vm.$store.state.globalSettings.licenseStatus == 4)
) {
(async function() {
await window.$gz.dialog.displayLTModalNotificationMessage(
"MaintenanceExpiredNote",
"MaintenanceExpired",
"error",
"https://www.ayanova.com/subscriptionexpired.htm"
);
})();
}
let toPath = vm.$route.params.topath; //set in app.vue::mounted
if (toPath != undefined) {
//check if it's an open report link and if so
//trigger that to open in a new window and continue on to normal home page
if (toPath.startsWith("/viewreport")) {
(async function() {
//open report links have a query string /viewreport?oid=[objectid]&rid=[reportid]
let searchParams = new URLSearchParams(vm.$route.params.search);
let objectId = parseInt(searchParams.get("oid"));
let reportId = parseInt(searchParams.get("rid"));
await window.$gz.api.renderReport(objectId, reportId); //objectid,reportid
})();
vm.$router.push(vm.$store.state.homePage);
} else {
//otherwise open the url indicated
vm.$router.push(vm.$route.params.topath);
}
} else {
vm.$router.push(vm.$store.state.homePage);
}
}
},
beforeRouteEnter(to, from, next) {