Skip to content

Commit

Permalink
Merge pull request #92 from City-of-Helsinki/fix/ym-223-redirect-stra…
Browse files Browse the repository at this point in the history
…ight-to-authentication

YM-223 | Redirect straight to authentication
  • Loading branch information
tuovinensanttu committed Jun 4, 2020
2 parents 3610270 + cafb44d commit a109d43
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import React from 'react';
import { shallow } from 'enzyme';
import { MemoryRouter } from 'react-router';

import App from './App';

it('renders without crashing', () => {
shallow(<App />);
shallow(
<MemoryRouter>
<App />
</MemoryRouter>
);
});
9 changes: 9 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { useLocation } from 'react-router-dom';
import { Switch, Route } from 'react-router';
import { ApolloProvider } from '@apollo/react-hooks';
import { Provider as ReduxProvider } from 'react-redux';
Expand All @@ -22,6 +23,7 @@ import AccessibilityStatement from './accessibilityStatement/AccessibilityStatem
import { MAIN_CONTENT_ID } from './common/constants';
import AccessibilityShortcuts from './common/accessibilityShortcuts/AccessibilityShortcuts';
import AppMeta from './AppMeta';
import authenticate from './auth/authenticate';

countries.registerLocale(fi);
countries.registerLocale(en);
Expand Down Expand Up @@ -52,6 +54,12 @@ if (process.env.REACT_APP_ENVIRONMENT !== 'production') {
type Props = {};

function App(props: Props) {
const location = useLocation();

if (location.pathname === '/loginsso') {
authenticate();
}

return (
<ReduxProvider store={store}>
<OidcProvider store={store} userManager={userManager}>
Expand Down Expand Up @@ -79,6 +87,7 @@ function App(props: Props) {
<Route path="/profile-deleted" exact>
<ProfileDeleted />
</Route>
<Route path="/loginsso" exact />
<Route path="*">404 - not found</Route>
</Switch>
</MatomoProvider>
Expand Down

0 comments on commit a109d43

Please sign in to comment.