diff --git a/awx/ui_next/src/App.jsx b/awx/ui_next/src/App.jsx
index 82fb7e99af..e88291fc7c 100644
--- a/awx/ui_next/src/App.jsx
+++ b/awx/ui_next/src/App.jsx
@@ -1,4 +1,5 @@
import React, { Component, Fragment } from 'react';
+import { withRouter } from 'react-router-dom';
import { global_breakpoint_md } from '@patternfly/react-tokens';
import {
Nav,
@@ -66,8 +67,9 @@ class App extends Component {
// eslint-disable-next-line class-methods-use-this
async handleLogout() {
+ const { history } = this.props;
await RootAPI.logout();
- window.location.replace('/#/login');
+ history.replace('/login');
}
handleAboutOpen() {
@@ -193,4 +195,4 @@ class App extends Component {
}
export { App as _App };
-export default withI18n()(App);
+export default withI18n()(withRouter(App));
diff --git a/awx/ui_next/src/index.jsx b/awx/ui_next/src/index.jsx
index 9fd10daf47..cd64f64e9d 100644
--- a/awx/ui_next/src/index.jsx
+++ b/awx/ui_next/src/index.jsx
@@ -43,7 +43,6 @@ export function main(render) {
const el = document.getElementById('app');
document.title = `Ansible ${BrandName}`;
- const defaultRedirect = () => ;
const removeTrailingSlash = (
}
/>
);
- const loginRoutes = (
-
- {removeTrailingSlash}
- }
- />
-
-
- );
+
+ const defaultRedirect = () => {
+ if (isAuthenticated(document.cookie)) {
+ return ;
+ }
+ return (
+
+ {removeTrailingSlash}
+ }
+ />
+
+
+ );
+ };
return render(
{({ i18n }) => (
- {!isAuthenticated(document.cookie) ? (
- loginRoutes
- ) : (
-
- {removeTrailingSlash}
-
-
- (
+
+ {removeTrailingSlash}
+
+
+ {
+ if (!isAuthenticated(document.cookie)) {
+ return ;
+ }
+ return (
{routeList};
}}
/>
- )}
- />
-
- )}
+ );
+ }}
+ />
+
)}