This commit is contained in:
@@ -4,11 +4,22 @@ import initialize from "./initialize";
|
||||
|
||||
export function processLogin(response) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
//check there is a response of some kind
|
||||
if (!response) {
|
||||
window.$gz.store.commit("logItem", "auth::processLogin -> no response");
|
||||
return reject();
|
||||
}
|
||||
|
||||
//is there an error?
|
||||
if (response.error) {
|
||||
return reject(response.error);
|
||||
}
|
||||
|
||||
//is token present?
|
||||
if (!response || !response.data || !response.data.token) {
|
||||
if (!response.data || !response.data.token) {
|
||||
window.$gz.store.commit(
|
||||
"logItem",
|
||||
"auth::processLogin -> response empty"
|
||||
"auth::processLogin -> response contains no data"
|
||||
);
|
||||
return reject();
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ export default {
|
||||
)
|
||||
.then(window.$gz.api.status)
|
||||
.then(window.$gz.api.json)
|
||||
// eslint-disable-next-line
|
||||
.then((response) => {
|
||||
window.$gz._.forEach(
|
||||
response.data,
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
<v-col cols="12" class="d-flex d-md-none">
|
||||
<v-img :src="require('../assets/logo.svg')" contain height="64"></v-img>
|
||||
</v-col>
|
||||
<v-col cols="12" md="7" offset-md="3">
|
||||
<gz-error :errorBoxMessage="formState.errorBoxMessage"></gz-error>
|
||||
</v-col>
|
||||
<template v-if="$ay.dev">
|
||||
<v-col cols="12" offset="md-6">
|
||||
<span class="title red--text">DEVELOPMENT MODE</span>
|
||||
@@ -70,11 +73,14 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
input: {
|
||||
username: "manager",
|
||||
password: "l3tm3in"
|
||||
// username: "manager",
|
||||
// password: "l3tm3in"
|
||||
username: "CustomerLimited",
|
||||
password: "CustomerLimited"
|
||||
},
|
||||
errorBadCreds: false,
|
||||
reveal: false
|
||||
reveal: false,
|
||||
formState: { errorBoxMessage: null }
|
||||
};
|
||||
},
|
||||
created() {
|
||||
@@ -90,23 +96,34 @@ export default {
|
||||
document.getElementsByName("password")[0].focus();
|
||||
},
|
||||
login() {
|
||||
if (this.input.username != "" && this.input.password != "") {
|
||||
this.errorBadCreds = false;
|
||||
let vm = this;
|
||||
let vm = this;
|
||||
if (vm.input.username != "" && vm.input.password != "") {
|
||||
vm.errorBadCreds = false;
|
||||
|
||||
auth
|
||||
.authenticate(this.input.username, this.input.password)
|
||||
.authenticate(vm.input.username, vm.input.password)
|
||||
.then(() => {
|
||||
vm.$router.push(vm.$store.state.homePage);
|
||||
})
|
||||
.catch(function handleCaughtLoginError(error) {
|
||||
/* xeslint-disable-next-line */
|
||||
//bad creds?
|
||||
if (
|
||||
error.message &&
|
||||
error.message.includes("ErrorUserNotAuthenticated")
|
||||
) {
|
||||
vm.errorBadCreds = true;
|
||||
}
|
||||
//server closed?
|
||||
if (error.code == 2000) {
|
||||
vm.formState.errorBoxMessage = error.message;
|
||||
}
|
||||
|
||||
// {
|
||||
// "code": "2000",
|
||||
// "message": "Testing ops only server state"
|
||||
// }
|
||||
//-----
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user