This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
/* Xeslint-disable */
|
/* Xeslint-disable */
|
||||||
import logger from "../utils/logit";
|
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -7,7 +6,7 @@ export default {
|
|||||||
if (response.status >= 200 && response.status < 300) {
|
if (response.status >= 200 && response.status < 300) {
|
||||||
return Promise.resolve(response);
|
return Promise.resolve(response);
|
||||||
} else {
|
} else {
|
||||||
logger.log("API error", response.statusText);
|
store.commit("logItem", "API error: " + response.statusText);
|
||||||
return Promise.reject(new Error(response.statusText));
|
return Promise.reject(new Error(response.statusText));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -67,7 +66,7 @@ export default {
|
|||||||
window.location.hostname == "localhost" &&
|
window.location.hostname == "localhost" &&
|
||||||
window.location.port == "8080"
|
window.location.port == "8080"
|
||||||
) {
|
) {
|
||||||
logger.log("apiutil::APIUrl -> APIURL empty setting to dev. mode");
|
store.commit("logItem", "apiutil::APIUrl -> setting to dev. mode");
|
||||||
store.commit("setAPIURL", "http://localhost:7575/api/v8.0/");
|
store.commit("setAPIURL", "http://localhost:7575/api/v8.0/");
|
||||||
} else {
|
} else {
|
||||||
//production location <protocol>//<hostname>:<port>/
|
//production location <protocol>//<hostname>:<port>/
|
||||||
@@ -75,9 +74,9 @@ export default {
|
|||||||
"setAPIURL",
|
"setAPIURL",
|
||||||
window.location.protocol + "//" + window.location.host + "/api/v8.0/"
|
window.location.protocol + "//" + window.location.host + "/api/v8.0/"
|
||||||
);
|
);
|
||||||
logger.log(
|
store.commit(
|
||||||
"apiutil::APIUrl -> APIURL empty using: ",
|
"logItem",
|
||||||
store.state.apiUrl
|
"apiutil::APIUrl -> setting to: " + store.state.apiUrl
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,26 @@
|
|||||||
/* xeslint-disable */
|
/* xeslint-disable */
|
||||||
import decode from "jwt-decode";
|
import decode from "jwt-decode";
|
||||||
import logger from "./logit";
|
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
import initialize from "./initialize";
|
import initialize from "./initialize";
|
||||||
|
|
||||||
export function processLogin(response) {
|
export function processLogin(response) {
|
||||||
//is token present?
|
//is token present?
|
||||||
if (!response || !response.data || !response.data.token) {
|
if (!response || !response.data || !response.data.token) {
|
||||||
logger.log("auth::processLogin -> token empty");
|
store.commit("logItem", "auth::processLogin -> response empty");
|
||||||
return Promise.reject();
|
return Promise.reject();
|
||||||
}
|
}
|
||||||
const token = decode(response.data.token);
|
const token = decode(response.data.token);
|
||||||
|
|
||||||
if (!token || !token.iss) {
|
if (!token || !token.iss) {
|
||||||
logger.log("auth::processLogin -> token empty");
|
store.commit("logItem", "auth::processLogin -> response token empty");
|
||||||
return Promise.reject();
|
return Promise.reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token.iss != "ayanova.com") {
|
if (token.iss != "ayanova.com") {
|
||||||
logger.log("auth::processLogin -> token invalid (iss)", token.iss);
|
store.commit(
|
||||||
|
"logItem",
|
||||||
|
"auth::processLogin -> token invalid (iss): " + token.iss
|
||||||
|
);
|
||||||
return Promise.reject();
|
return Promise.reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,12 +34,15 @@ export function processLogin(response) {
|
|||||||
|
|
||||||
//Initialize the application
|
//Initialize the application
|
||||||
initialize();
|
initialize();
|
||||||
logger.log("User " + token.id + " logged in");
|
store.commit(
|
||||||
|
"logItem",
|
||||||
|
"auth::processLogin -> User " + token.id + " logged in"
|
||||||
|
);
|
||||||
return Promise.resolve(true);
|
return Promise.resolve(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function processLogout() {
|
export function processLogout() {
|
||||||
logger.log("Logout");
|
store.commit("logItem", "auth::processLogout -> User logged out");
|
||||||
store.commit("logout");
|
store.commit("logout");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/* xeslint-disable */
|
/* xeslint-disable */
|
||||||
import logger from "./logit";
|
|
||||||
import store from "../store";
|
import store from "../store";
|
||||||
import roles from "./roles";
|
import roles from "./roles";
|
||||||
import lt from "../api/locale";
|
import lt from "../api/locale";
|
||||||
@@ -84,7 +83,8 @@ export default function initialize() {
|
|||||||
addNavItem(lt.get("Logout"), "sign-out-alt", "/login");
|
addNavItem(lt.get("Logout"), "sign-out-alt", "/login");
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function(error) {
|
||||||
logger.log("Initialize::() -> error", error);
|
store.commit("logItem", "Initialize::() -> error" + error);
|
||||||
|
throw error;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
/* xeslint-disable */
|
|
||||||
//////////////////////////////////////////////////////
|
|
||||||
//in-memory log, keeps up to 100 of the past log items
|
|
||||||
//
|
|
||||||
import cbuffer from "./cbuffer";
|
|
||||||
import store from "../store";
|
|
||||||
|
|
||||||
const buffer = new cbuffer(100);
|
|
||||||
export default {
|
|
||||||
log(msg, obj) {
|
|
||||||
if (obj) {
|
|
||||||
msg = msg + "|[" + JSON.stringify(obj) + "]";
|
|
||||||
}
|
|
||||||
msg = Date.now() + "|" + msg;
|
|
||||||
buffer.push(msg);
|
|
||||||
store.commit("setLog", buffer.toArray());
|
|
||||||
},
|
|
||||||
getLogText() {
|
|
||||||
//TODO: iterate the array from store, convert timestamps to local date and time and arrange as a block of multiline text to display in the UI
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<span>{{log()}}</span>
|
<span>{{log()}}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
/* xeslint-disable */
|
/* xeslint-disable */
|
||||||
|
|
||||||
import logger from "../utils/logit";
|
|
||||||
//import lt from "../api/locale";
|
//import lt from "../api/locale";
|
||||||
//import store from "../store";
|
import store from "../store";
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {};
|
return {};
|
||||||
@@ -18,7 +17,7 @@ export default {
|
|||||||
mounted() {},
|
mounted() {},
|
||||||
methods: {
|
methods: {
|
||||||
log: function() {
|
log: function() {
|
||||||
logger.getLogText();
|
return store.state.logArray;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user