web/satellite: fix Vuex state clearing on session timeout
Fixed Vuex state clearing on session timeout. Now state is being cleared right after redirect to login and before logout API call. Change-Id: I3cddb85735899f0913a273a49335730a4097435e
This commit is contained in:
parent
d6a948f59d
commit
d1c230fe4d
@ -134,15 +134,6 @@ export default class AccountArea extends Vue {
|
||||
this.analytics.pageVisit(RouteConfig.Login.path);
|
||||
await this.$router.push(RouteConfig.Login.path);
|
||||
|
||||
try {
|
||||
this.analytics.eventTriggered(AnalyticsEvent.LOGOUT_CLICKED);
|
||||
await this.auth.logout();
|
||||
} catch (error) {
|
||||
await this.$notify.error(error.message, AnalyticsErrorEventSource.NAVIGATION_ACCOUNT_AREA);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
this.$store.dispatch(PM_ACTIONS.CLEAR),
|
||||
this.$store.dispatch(PROJECTS_ACTIONS.CLEAR),
|
||||
@ -158,7 +149,12 @@ export default class AccountArea extends Vue {
|
||||
this.$store.dispatch('files/clear'),
|
||||
]);
|
||||
|
||||
LocalData.removeUserId();
|
||||
try {
|
||||
this.analytics.eventTriggered(AnalyticsEvent.LOGOUT_CLICKED);
|
||||
await this.auth.logout();
|
||||
} catch (error) {
|
||||
await this.$notify.error(error.message, AnalyticsErrorEventSource.NAVIGATION_ACCOUNT_AREA);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -486,28 +486,27 @@ export default class MobileNavigation extends Vue {
|
||||
this.analytics.pageVisit(RouteConfig.Login.path);
|
||||
await this.$router.push(RouteConfig.Login.path);
|
||||
|
||||
await Promise.all([
|
||||
this.$store.dispatch(PM_ACTIONS.CLEAR),
|
||||
this.$store.dispatch(PROJECTS_ACTIONS.CLEAR),
|
||||
this.$store.dispatch(USER_ACTIONS.CLEAR),
|
||||
this.$store.dispatch(ACCESS_GRANTS_ACTIONS.STOP_ACCESS_GRANTS_WEB_WORKER),
|
||||
this.$store.dispatch(ACCESS_GRANTS_ACTIONS.CLEAR),
|
||||
this.$store.dispatch(NOTIFICATION_ACTIONS.CLEAR),
|
||||
this.$store.dispatch(BUCKET_ACTIONS.CLEAR),
|
||||
this.$store.dispatch(OBJECTS_ACTIONS.CLEAR),
|
||||
this.$store.dispatch(APP_STATE_ACTIONS.CLEAR),
|
||||
this.$store.dispatch(PAYMENTS_ACTIONS.CLEAR_PAYMENT_INFO),
|
||||
this.$store.dispatch(AB_TESTING_ACTIONS.RESET),
|
||||
this.$store.dispatch('files/clear'),
|
||||
]);
|
||||
|
||||
try {
|
||||
this.analytics.eventTriggered(AnalyticsEvent.LOGOUT_CLICKED);
|
||||
await this.auth.logout();
|
||||
} catch (error) {
|
||||
await this.$notify.error(error.message, AnalyticsErrorEventSource.MOBILE_NAVIGATION);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
await this.$store.dispatch(PM_ACTIONS.CLEAR);
|
||||
await this.$store.dispatch(PROJECTS_ACTIONS.CLEAR);
|
||||
await this.$store.dispatch(USER_ACTIONS.CLEAR);
|
||||
await this.$store.dispatch(ACCESS_GRANTS_ACTIONS.CLEAR);
|
||||
await this.$store.dispatch(ACCESS_GRANTS_ACTIONS.STOP_ACCESS_GRANTS_WEB_WORKER);
|
||||
await this.$store.dispatch(NOTIFICATION_ACTIONS.CLEAR);
|
||||
await this.$store.dispatch(BUCKET_ACTIONS.CLEAR);
|
||||
await this.$store.dispatch(OBJECTS_ACTIONS.CLEAR);
|
||||
await this.$store.dispatch(APP_STATE_ACTIONS.CLOSE_POPUPS);
|
||||
await this.$store.dispatch(PAYMENTS_ACTIONS.CLEAR_PAYMENT_INFO);
|
||||
await this.$store.dispatch(AB_TESTING_ACTIONS.RESET);
|
||||
|
||||
LocalData.removeUserId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,9 +5,7 @@
|
||||
* LocalData exposes methods to manage local storage.
|
||||
*/
|
||||
export class LocalData {
|
||||
private static userId = 'userId';
|
||||
private static selectedProjectId = 'selectedProjectId';
|
||||
private static userIdPassSalt = 'userIdPassSalt';
|
||||
private static demoBucketCreated = 'demoBucketCreated';
|
||||
private static bucketGuideHidden = 'bucketGuideHidden';
|
||||
private static serverSideEncryptionBannerHidden = 'serverSideEncryptionBannerHidden';
|
||||
@ -15,18 +13,6 @@ export class LocalData {
|
||||
private static billingNotificationAcknowledged = 'billingNotificationAcknowledged';
|
||||
private static sessionExpirationDate = 'sessionExpirationDate';
|
||||
|
||||
public static getUserId(): string | null {
|
||||
return localStorage.getItem(LocalData.userId);
|
||||
}
|
||||
|
||||
public static setUserId(id: string): void {
|
||||
localStorage.setItem(LocalData.userId, id);
|
||||
}
|
||||
|
||||
public static removeUserId(): void {
|
||||
localStorage.removeItem(LocalData.userId);
|
||||
}
|
||||
|
||||
public static getSelectedProjectId(): string | null {
|
||||
return localStorage.getItem(LocalData.selectedProjectId);
|
||||
}
|
||||
@ -39,23 +25,6 @@ export class LocalData {
|
||||
localStorage.removeItem(LocalData.selectedProjectId);
|
||||
}
|
||||
|
||||
public static getUserIDPassSalt(): UserIDPassSalt | null {
|
||||
const data: string | null = localStorage.getItem(LocalData.userIdPassSalt);
|
||||
if (data) {
|
||||
const parsed = JSON.parse(data);
|
||||
|
||||
return new UserIDPassSalt(parsed.userId, parsed.passwordHash, parsed.salt);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static setUserIDPassSalt(id: string, passwordHash: string, salt: string): void {
|
||||
const data = new UserIDPassSalt(id, passwordHash, salt);
|
||||
|
||||
localStorage.setItem(LocalData.userIdPassSalt, JSON.stringify(data));
|
||||
}
|
||||
|
||||
public static getDemoBucketCreatedStatus(): string | null {
|
||||
const status = localStorage.getItem(LocalData.demoBucketCreated);
|
||||
if (!status) return null;
|
||||
@ -110,7 +79,7 @@ export class LocalData {
|
||||
public static setBillingNotificationAcknowledged(): void {
|
||||
localStorage.setItem(LocalData.billingNotificationAcknowledged, 'true');
|
||||
}
|
||||
|
||||
|
||||
public static getSessionExpirationDate(): Date | null {
|
||||
const data: string | null = localStorage.getItem(LocalData.sessionExpirationDate);
|
||||
if (data) {
|
||||
@ -124,14 +93,3 @@ export class LocalData {
|
||||
localStorage.setItem(LocalData.sessionExpirationDate, date.toISOString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UserIDPassSalt is an entity holding user id, password hash and salt to be stored in local storage.
|
||||
*/
|
||||
export class UserIDPassSalt {
|
||||
public constructor(
|
||||
public userId: string = '',
|
||||
public passwordHash: string = '',
|
||||
public salt: string = '',
|
||||
) {}
|
||||
}
|
||||
|
@ -427,20 +427,6 @@ async function handleInactive(): Promise<void> {
|
||||
await analytics.pageVisit(RouteConfig.Login.path);
|
||||
await router.push(RouteConfig.Login.path);
|
||||
|
||||
resetActivityEvents.forEach((eventName: string) => {
|
||||
document.removeEventListener(eventName, onSessionActivity);
|
||||
});
|
||||
clearSessionTimers();
|
||||
inactivityModalShown.value = false;
|
||||
|
||||
try {
|
||||
await auth.logout();
|
||||
} catch (error) {
|
||||
if (error instanceof ErrorUnauthorized) return;
|
||||
|
||||
await notify.error(error.message, AnalyticsErrorEventSource.OVERALL_SESSION_EXPIRED_ERROR);
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
store.dispatch(PM_ACTIONS.CLEAR),
|
||||
store.dispatch(PROJECTS_ACTIONS.CLEAR),
|
||||
@ -455,6 +441,20 @@ async function handleInactive(): Promise<void> {
|
||||
store.dispatch(AB_TESTING_ACTIONS.RESET),
|
||||
store.dispatch('files/clear'),
|
||||
]);
|
||||
|
||||
resetActivityEvents.forEach((eventName: string) => {
|
||||
document.removeEventListener(eventName, onSessionActivity);
|
||||
});
|
||||
clearSessionTimers();
|
||||
inactivityModalShown.value = false;
|
||||
|
||||
try {
|
||||
await auth.logout();
|
||||
} catch (error) {
|
||||
if (error instanceof ErrorUnauthorized) return;
|
||||
|
||||
await notify.error(error.message, AnalyticsErrorEventSource.OVERALL_SESSION_EXPIRED_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
function setIsLimitModalShown(value: boolean): void {
|
||||
|
Loading…
Reference in New Issue
Block a user