F #5786: fireedge only use localStorage (#1898)

This commit is contained in:
Jorge Miguel Lobo Escalona authored and GitHub committed 2022-04-01 11:57:08 +02:00
1 parent 6141e593cd
commit 7fcd57f72a
6 files changed
+15 -24

No files matched your search

+3 -2
View File
@@ -20,11 +20,12 @@ one_xmlrpc: 'http://localhost:2633/RPC2'
# Flow Server: use it if you have flow-server and fireedge on different servers
oneflow_server: 'http://localhost:2474'
# life expiration time (minutes)
session_expiration: 180
# life expiration time when use the check remember into login (minutes)
session_remember_expiration: 3600
# minimum life expiration time (minutes)
minimun_opennebula_expiration: 30
@@ -88,12 +88,12 @@ const authApi = createApi({
isLoginInProgress: withGroupSwitcher && !!token && !isOneAdmin,
}
},
async onQueryStarted({ remember }, { queryFulfilled, dispatch }) {
async onQueryStarted(_, { queryFulfilled, dispatch }) {
try {
const { data: queryData } = await queryFulfilled
if (queryData?.jwt) {
storage(JWT_NAME, queryData?.jwt, remember)
storage(JWT_NAME, queryData?.jwt)
dispatch(dismissSnackbar({ dismissAll: true }))
}
@@ -28,7 +28,6 @@ const initial = {
withGroupSwitcher: false,
isLoading: false,
isFixMenu: false,
notifications: [],
}
+5 -16
View File
@@ -18,19 +18,11 @@ import root from 'window-or-global'
/**
* Save an item in the browser storage.
*
* @param {string} name
* - Name of item in the storage
* @param {string} data
* - Data will be saved into storage
* @param {boolean} keepData
* - If `true`, save the data in local storage, instead of session storage
* @param {string} name - Name of item in the storage
* @param {string} data - The data will be saved into local storage
*/
export const storage = (name = '', data = '', keepData = false) => {
if (name && data) {
keepData
? root?.localStorage?.setItem(name, data)
: root?.sessionStorage?.setItem(name, data)
}
export const storage = (name = '', data = '') => {
name && data && root?.localStorage?.setItem(name, data)
}
/**
@@ -43,7 +35,6 @@ export const removeStoreData = (items = []) => {
itemsToRemove.forEach((item) => {
root?.localStorage?.removeItem(item)
root?.sessionStorage?.removeItem(item)
})
}
@@ -51,13 +42,11 @@ export const removeStoreData = (items = []) => {
* Looking for an item in the browser storage.
*
* @param {string} name - Name of item
* @returns {object|string} Returns the item if found it
* @returns {false|string} Returns the item if found it
*/
export const findStorageData = (name = '') => {
if (name && root?.localStorage?.getItem(name)) {
return root.localStorage.getItem(name)
} else if (name && root?.sessionStorage?.getItem(name)) {
return root.sessionStorage.getItem(name)
} else return false
}
@@ -201,7 +201,7 @@ const setRes = (newRes = {}) => {
*/
const setDates = () => {
limitToken = remember
? appConfig.session__remember_expiration || defaultRememberSessionExpiration
? appConfig.session_remember_expiration || defaultRememberSessionExpiration
: appConfig.session_expiration || defaultSessionExpiration
limitExpirationReuseToken =
parseInt(appConfig.session_reuse_token_time, 10) ||
@@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and *
* limitations under the License. *
* ------------------------------------------------------------------------- */
// eslint-disable-next-line node/no-deprecated-api
const { parse } = require('url')
const { Router } = require('express')
const { renderToString } = require('react-dom/server')
const root = require('window-or-global')
@@ -42,8 +44,8 @@ const router = Router()
router.get('*', (req, res) => {
const apps = Object.keys(defaultApps)
const appName = req.url
.split(/\//gi)
const appName = parse(req.url)
.pathname.split(/\//gi)
.filter((sub) => sub?.length > 0)
.find((resource) => apps.includes(resource))