From e0359d5de87a0a958bfc408ef7466a2127cf94ec Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 10 Jun 2020 23:51:25 +0000 Subject: [PATCH] --- ayanova/cypress.json | 2 +- ayanova/src/api/auth.js | 4 +- ayanova/src/api/authutil.js | 26 +++++++----- ayanova/src/api/initialize.js | 14 ++++++- ayanova/src/store.js | 7 +++- ayanova/src/views/adm-launch.vue | 62 ++++++++++++++++++++++++++++- ayanova/src/views/home-password.vue | 9 +++++ ayanova/src/views/login.vue | 4 +- 8 files changed, 109 insertions(+), 19 deletions(-) diff --git a/ayanova/cypress.json b/ayanova/cypress.json index b8a9a751..f8f28e89 100644 --- a/ayanova/cypress.json +++ b/ayanova/cypress.json @@ -2,7 +2,7 @@ "pluginsFile": "tests/e2e/plugins/index.js", "baseUrl": "http://localhost:8080", "env": { - "adminusername": "manager", + "adminusername": "superuser", "adminpassword": "l3tm3in" } } \ No newline at end of file diff --git a/ayanova/src/api/auth.js b/ayanova/src/api/auth.js index c3078bf0..7c31ef96 100644 --- a/ayanova/src/api/auth.js +++ b/ayanova/src/api/auth.js @@ -6,6 +6,8 @@ export default { async authenticate(login, password) { return new Promise(async function doAuth(resolve, reject) { try { + let loggedInWithKnownPassword = + login == "superuser" && password == "l3tm3in"; let fetchData = await fetch( window.$gz.api.APIUrl("auth"), window.$gz.api.fetchPostNoAuthOptions({ @@ -15,7 +17,7 @@ export default { ); fetchData = await window.$gz.api.status(fetchData); fetchData = await window.$gz.api.extractBody(fetchData); - await processLogin(fetchData); + await processLogin(fetchData, loggedInWithKnownPassword); resolve(); } catch (e) { reject(e); diff --git a/ayanova/src/api/authutil.js b/ayanova/src/api/authutil.js index 54ef4a03..5f36e201 100644 --- a/ayanova/src/api/authutil.js +++ b/ayanova/src/api/authutil.js @@ -2,29 +2,29 @@ import decode from "jwt-decode"; import initialize from "./initialize"; -export function processLogin(response) { +export function processLogin(authResponse, loggedInWithKnownPassword) { return new Promise(async function(resolve, reject) { try { //check there is a response of some kind - if (!response) { + if (!authResponse) { window.$gz.store.commit("logItem", "auth::processLogin -> no response"); return reject(); } //is there an error? - if (response.error) { - return reject(response.error); + if (authResponse.error) { + return reject(authResponse.error); } //is token present? - if (!response.data || !response.data.token) { + if (!authResponse.data || !authResponse.data.token) { window.$gz.store.commit( "logItem", "auth::processLogin -> response contains no data" ); return reject(); } - const token = decode(response.data.token); + const token = decode(authResponse.data.token); if (!token || !token.iss) { window.$gz.store.commit( @@ -46,15 +46,19 @@ export function processLogin(response) { window.$gz.store.commit("logout"); sessionStorage.clear(); //clear all temporary session storage data + //encourage password changing if a purchased license + if (loggedInWithKnownPassword) + window.$gz.store.commit("setKnownPassword", true); + //Put app relevant items into vuex store so app can use them window.$gz.store.commit("login", { - apiToken: response.data.token, + apiToken: authResponse.data.token, authenticated: true, userId: Number(token.id), - userName: response.data.name, - roles: response.data.roles, - userType: response.data.usertype, - dlt: response.data.dlt + userName: authResponse.data.name, + roles: authResponse.data.roles, + userType: authResponse.data.usertype, + dlt: authResponse.data.dlt }); //log the login window.$gz.store.commit( diff --git a/ayanova/src/api/initialize.js b/ayanova/src/api/initialize.js index c2bbf80d..895beaa3 100644 --- a/ayanova/src/api/initialize.js +++ b/ayanova/src/api/initialize.js @@ -14,7 +14,7 @@ function addNavItem(title, icon, route, navItems, key, testid) { }); } -function initNavPanal() { +function initNavPanel() { let key = 0; let sub = []; @@ -777,8 +777,18 @@ export default function initialize() { await window.$gz.translation.cacheTranslations( window.$gz.translation.coreKeys ); - await initNavPanal(); + initNavPanel(); await getUserOptions(); + + //check for known password and a purchased licensed mode + if ( + window.$gz.store.state.knownPassword && + (window.$gz.store.state.globalSettings.licenseStatus == 3 || //ActivePurchased = 3, + window.$gz.store.state.globalSettings.licenseStatus == 4) // ExpiredPurchased = 4 + ) { + window.$gz.store.commit("setHomePage", "/home-password"); + } + resolve(); } catch (err) { reject(err); diff --git a/ayanova/src/store.js b/ayanova/src/store.js index 91732318..b793b6b2 100644 --- a/ayanova/src/store.js +++ b/ayanova/src/store.js @@ -44,7 +44,8 @@ export default new Vuex.Store({ logArray: [], formSettings: {}, //this is the settings on forms that survive a refresh like grid number of items to show etc formCustomTemplate: {}, //this is the custom fields settings for forms, - darkMode: false + darkMode: false, + knownPassword: false }, mutations: { setLastClientVersion(state, data) { @@ -80,6 +81,7 @@ export default new Vuex.Store({ state.locale.currencyName = "USD"; state.locale.hour12 = true; state.globalSettings = {}; + state.knownPassword = false; }, addNavItem(state, data) { state.navItems.push(data); @@ -144,6 +146,9 @@ export default new Vuex.Store({ }, setDarkMode(state, data) { state.darkMode = data; + }, + setKnownPassword(state, data) { + state.knownPassword = data; } }, actions: {} diff --git a/ayanova/src/views/adm-launch.vue b/ayanova/src/views/adm-launch.vue index c797e237..12878774 100644 --- a/ayanova/src/views/adm-launch.vue +++ b/ayanova/src/views/adm-launch.vue @@ -4,7 +4,63 @@ -

Launch

+ + + + Select an app + Summarize if needed + + + + + Continue + Cancel + + + Configure analytics for this app + + + + Continue + Cancel + + + Select an ad format and name ad unit + + + + Continue + Cancel + + + View setup instructions + + + Continue + Cancel + + +
@@ -60,6 +116,7 @@ export default { selectLists: { translations: [] }, + currentStep: 1, obj: {}, formState: { ready: false, @@ -100,6 +157,9 @@ export default { } }, methods: { + completeStep() { + return 1; + }, translation() { return window.$gz.translation; }, diff --git a/ayanova/src/views/home-password.vue b/ayanova/src/views/home-password.vue index 2970a14a..50b6a37a 100644 --- a/ayanova/src/views/home-password.vue +++ b/ayanova/src/views/home-password.vue @@ -106,6 +106,15 @@ export default { readOnly: false }); window.$gz.eventBus.$on("menu-click", clickHandler); + + //Set known password warning if applicable + if ( + window.$gz.store.state.knownPassword && + (window.$gz.store.state.globalSettings.licenseStatus == 3 || //ActivePurchased = 3, + window.$gz.store.state.globalSettings.licenseStatus == 4) // ExpiredPurchased = 4 + ) { + this.formState.errorBoxMessage = vm.$ay.t("KnownPasswordWarning"); + } }) .catch(err => { vm.formState.ready = true; diff --git a/ayanova/src/views/login.vue b/ayanova/src/views/login.vue index c29a4d10..8d172b9f 100644 --- a/ayanova/src/views/login.vue +++ b/ayanova/src/views/login.vue @@ -91,7 +91,7 @@ export default { data() { return { input: { - username: "manager", + username: "superuser", password: "l3tm3in" }, @@ -104,7 +104,7 @@ export default { trialUsers: [ { name: "AyaNova administrator - all", - l: "manager", + l: "superuser", p: "l3tm3in" }, {