PromucFlow_constructor/app/client/src/utils/storage.ts
Hetu Nandu a29dccbaf0
First time page load performance (#144)
* WIP

* Chunk names

* Add auth call

* add auth

* WIP

* Auth management setup

* fix a test

* fix cypress machine count

* some more changes

* fix header link

* check for auth

* fix import

* fix imports

* Use auth class

* WIP

* Better loading

* Remove unused

* Remove qs

* Auth loader

* Redirect for login

* Third part auth

* 404 redirects

* 404 page handling

* Adding custom docker image for performance fixes

* Correcting the workflow to get package step to run

* Clean up

* lazy auth load

* remove assertions from delete app and logout calls

* remove github workflow changes

* roll back lazy auth

* Error handling

* test editor chunk suspense

* Show header in editor before initialization

* Changes for app view

* Login header fixes

* Loader fixes

* Fix base login routes

Co-authored-by: Arpit Mohan <arpit@appsmith.com>
2020-08-03 19:48:48 +05:30

29 lines
720 B
TypeScript

import localforage from "localforage";
import moment from "moment";
const STORAGE_KEYS: { [id: string]: string } = {
AUTH_EXPIRATION: "Auth.expiration",
ROUTE_BEFORE_LOGIN: "RedirectPath",
};
const store = localforage.createInstance({
name: "Appsmith",
});
export const resetAuthExpiration = () => {
const expireBy = moment()
.add(1, "h")
.format();
store.setItem(STORAGE_KEYS.AUTH_EXPIRATION, expireBy).catch(error => {
console.log("Unable to set expiration time");
});
};
export const hasAuthExpired = async () => {
const expireBy: string = await store.getItem(STORAGE_KEYS.AUTH_EXPIRATION);
if (expireBy && moment().isAfter(moment(expireBy))) {
return true;
}
return false;
};