Skip to content
Open

fix #556

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/Service.Host/client/src/components/common/SearchPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ const useStyles = makeStyles(() => ({
},
paper: {
backgroundColor: '#f5f5f5',
position: 'relative',
zIndex: -1
position: 'fixed',
zIndex: 1000,
paddingTop: '80px',
width: '100%',
overflow: 'auto',
height: '100vh'
},
menuItems: {
fontSize: '12px',
Expand All @@ -29,10 +33,9 @@ const useStyles = makeStyles(() => ({
closeButton: {
marginRight: '10px',
marginTop: '10px',
position: 'absolute',
float: 'right',
top: 0,
right: 0,
zIndex: 1
right: 0
},
searchInputField: {
float: 'right'
Expand Down
48 changes: 29 additions & 19 deletions src/Service.Host/client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AppContainer } from 'react-hot-loader';
import { SnackbarProvider } from 'notistack';
import { linnTheme } from '@linn-it/linn-form-components-library';
import { ThemeProvider } from '@material-ui/styles';
import { loadUser } from 'redux-oidc';
import configureStore from './configureStore';
import Root from './components/Root';
import userManager from './helpers/userManager';
Expand All @@ -14,7 +15,6 @@ const NextRoot = require('./components/Root').default;

const initialState = {};
const store = configureStore(initialState);
const { user } = store.getState().oidc;

const render = Component => {
ReactDOM.render(
Expand All @@ -29,22 +29,32 @@ const render = Component => {
);
};

if (
(!user || user.expired) &&
window.location.pathname !== '/inventory/auth/' &&
window.location.pathname !== '/inventory/auth/logged-out'
) {
userManager.signinRedirect({
data: { redirect: window.location.pathname + window.location.search }
});
} else {
render(Root);
loadUser(store, userManager);

userManager
.getUser()
.then(user => {
if (
(!user || user.expired) &&
window.location.pathname !== '/inventory/auth/' &&
window.location.pathname !== '/inventory/auth/logged-out'
) {
userManager.signinRedirect({
data: { redirect: window.location.pathname + window.location.search }
});
} else {
render(Root);

// Hot Module Replacement API
if (module.hot) {
//module.hot.accept('./reducers', () => store.replaceReducer(reducer));
module.hot.accept('./components/Root', () => {
render(NextRoot);
});
}
}
// Hot Module Replacement API
if (module.hot) {
//module.hot.accept('./reducers', () => store.replaceReducer(reducer));
module.hot.accept('./components/Root', () => {
render(NextRoot);
});
}
}
})
.catch(error => {
console.error('Error loading user:', error);
render(Root);
});
13 changes: 7 additions & 6 deletions src/Service.Host/client/src/middleware/authorization.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { RSAA } from 'redux-api-middleware';
import { getAccessToken } from '../selectors/getAccessToken';
import { addressesActionTypes as actionTypes } from '../actions/index';
import { addressesActionTypes } from '../actions';

export default ({ getState }) => next => action => {
console.log(action[RSAA]?.types);
console.log(addressesActionTypes.REQUEST_SEARCH_ADDRESSES);
if (action[RSAA]) {
if (action[RSAA].options
&& action[RSAA].options.requiresAuth
&& !action[RSAA]?.types?.some(t => t.type === addressesActionTypes.REQUEST_SEARCH_ADDRESSES)) {
if (
action[RSAA].options &&
action[RSAA].options.requiresAuth &&
!action[RSAA]?.types?.some(
t => t.type === addressesActionTypes.REQUEST_SEARCH_ADDRESSES
)
) {
// eslint-disable-next-line no-param-reassign
action[RSAA].headers = {
Authorization: `Bearer ${getAccessToken(getState())}`,
Expand Down