This commit is contained in:
2018-11-07 23:12:00 +00:00
parent d99fe5677b
commit 063b68c9b9
4 changed files with 19 additions and 12 deletions

View File

@@ -64,23 +64,29 @@ export function processLogin(response) {
//response.data.token //response.data.token
//store token in central store //store token in central store
//todo: put token into localstorage later once this validation is worked out //todo: put token into localstorage later once this validation is worked out
logger.log("auth::processLogin called");
//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"); 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.iss != "ayanova.com") {
if (!token || !token.iss || token.iss != "ayanova.com") { logger.log("auth::processLogin -> token invalid (iss)", token.iss);
logger.log("auth::processLogin -> token empty or invalid "); return Promise.reject();
return Promise.resolve(false);
} }
//debugger;
config.apiToken = response.data.token; config.apiToken = response.data.token;
config.userId = Number(token.id); config.userId = Number(token.id);
config.roles = token["ayanova/roles"]; config.roles = token["ayanova/roles"];
logger.log("User " + token.id + " logged in");
return Promise.resolve(true); return Promise.resolve(true);
} }
@@ -89,7 +95,7 @@ export function processLogin(response) {
// }); // });
export function processLogout() { export function processLogout() {
logger.log("util\\auth.js->ProcessLogout called!"); logger.log("Logout");
clearToken(); clearToken();
//router.go('/'); //router.go('/');
} }

View File

@@ -1,7 +1,9 @@
/* eslint-disable */ //////////////////////////////////////////////////////
//in-memory log, keeps up to 100 of the past log items
//
import cbuffer from "./cbuffer"; import cbuffer from "./cbuffer";
const buffer = new cbuffer(10); const buffer = new cbuffer(100);
export default { export default {
log(msg, obj) { log(msg, obj) {
if (obj) { if (obj) {

View File

@@ -23,7 +23,6 @@ export default {
}, },
methods: { methods: {
login() { login() {
logger.log("User logging in: " + this.input.username);
if (this.input.username != "" && this.input.password != "") { if (this.input.username != "" && this.input.password != "") {
auth auth
.authenticate(this.input.username, this.input.password) .authenticate(this.input.username, this.input.password)

View File

@@ -30,7 +30,7 @@ refs:
WEEK OF 2018-11-05 - RAVEN shell start work. YAY! 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 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: - 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) - 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 - Proper graphics all over