From 063b68c9b9d8e3ab8563718d9f1e23a76730de88 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 7 Nov 2018 23:12:00 +0000 Subject: [PATCH] --- app/ayanova/src/utils/auth.js | 22 ++++++++++++++-------- app/ayanova/src/utils/logit.js | 6 ++++-- app/ayanova/src/views/login.vue | 1 - devdocs/todo.txt | 2 +- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/ayanova/src/utils/auth.js b/app/ayanova/src/utils/auth.js index 5c16a710..18dd047d 100644 --- a/app/ayanova/src/utils/auth.js +++ b/app/ayanova/src/utils/auth.js @@ -64,23 +64,29 @@ export function processLogin(response) { //response.data.token //store token in central store //todo: put token into localstorage later once this validation is worked out - logger.log("auth::processLogin called"); //is token present? if (!response || !response.data || !response.data.token) { logger.log("auth::processLogin -> token empty"); - return Promise.resolve(false); + return Promise.reject(); + } + const token = decode(response.data.token); + + if (!token || !token.iss) { + logger.log("auth::processLogin -> token empty"); + return Promise.reject(); } - const token = decode(response.data.token); - if (!token || !token.iss || token.iss != "ayanova.com") { - logger.log("auth::processLogin -> token empty or invalid "); - return Promise.resolve(false); + if (token.iss != "ayanova.com") { + logger.log("auth::processLogin -> token invalid (iss)", token.iss); + return Promise.reject(); } - //debugger; + config.apiToken = response.data.token; config.userId = Number(token.id); config.roles = token["ayanova/roles"]; + + logger.log("User " + token.id + " logged in"); return Promise.resolve(true); } @@ -89,7 +95,7 @@ export function processLogin(response) { // }); export function processLogout() { - logger.log("util\\auth.js->ProcessLogout called!"); + logger.log("Logout"); clearToken(); //router.go('/'); } diff --git a/app/ayanova/src/utils/logit.js b/app/ayanova/src/utils/logit.js index b5dd0a08..e64f2e71 100644 --- a/app/ayanova/src/utils/logit.js +++ b/app/ayanova/src/utils/logit.js @@ -1,7 +1,9 @@ -/* eslint-disable */ +////////////////////////////////////////////////////// +//in-memory log, keeps up to 100 of the past log items +// import cbuffer from "./cbuffer"; -const buffer = new cbuffer(10); +const buffer = new cbuffer(100); export default { log(msg, obj) { if (obj) { diff --git a/app/ayanova/src/views/login.vue b/app/ayanova/src/views/login.vue index e007d1a4..1978b9ad 100644 --- a/app/ayanova/src/views/login.vue +++ b/app/ayanova/src/views/login.vue @@ -23,7 +23,6 @@ export default { }, methods: { login() { - logger.log("User logging in: " + this.input.username); if (this.input.username != "" && this.input.password != "") { auth .authenticate(this.input.username, this.input.password) diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 6b868cb9..1b50758f 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -30,7 +30,7 @@ refs: WEEK OF 2018-11-05 - RAVEN shell start work. YAY! NEXT: Test authorization code to login even if just doing it from code for now to ensure that roles enum stuff works and payload is properly verified and decoded - +/* eslint-disable */ - Stage 1: - Make a rough but relevent shell with the idea of this being the actual release shell (Refine on the fly rather than re-do) - Proper graphics all over