Skip to content

Commit

Permalink
F #5786: fireedge only use localStorage (#1898)
Browse files Browse the repository at this point in the history
  • Loading branch information
jloboescalona2 authored Apr 1, 2022
1 parent 6141e59 commit 7fcd57f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 24 deletions.
5 changes: 3 additions & 2 deletions src/fireedge/etc/fireedge-server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/fireedge/src/client/features/AuthApi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }))
}

Expand Down
1 change: 0 additions & 1 deletion src/fireedge/src/client/features/General/slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const initial = {
withGroupSwitcher: false,
isLoading: false,
isFixMenu: false,

notifications: [],
}

Expand Down
21 changes: 5 additions & 16 deletions src/fireedge/src/client/utils/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

/**
Expand All @@ -43,21 +35,18 @@ export const removeStoreData = (items = []) => {

itemsToRemove.forEach((item) => {
root?.localStorage?.removeItem(item)
root?.sessionStorage?.removeItem(item)
})
}

/**
* 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
}

Expand Down
2 changes: 1 addition & 1 deletion src/fireedge/src/server/routes/api/auth/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down
6 changes: 4 additions & 2 deletions src/fireedge/src/server/routes/entrypoints/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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))

Expand Down

0 comments on commit 7fcd57f

Please sign in to comment.