This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user