diff --git a/spiffworkflow-frontend/src/App.tsx b/spiffworkflow-frontend/src/App.tsx
index fc2bf60e..998a6605 100644
--- a/spiffworkflow-frontend/src/App.tsx
+++ b/spiffworkflow-frontend/src/App.tsx
@@ -3,16 +3,10 @@ import { defineAbility } from '@casl/ability';
import React from 'react';
import { AbilityContext } from './contexts/Can';
-import UserService from './services/UserService';
import APIErrorProvider from './contexts/APIErrorContext';
import ContainerForExtensions from './ContainerForExtensions';
export default function App() {
- if (!UserService.isLoggedIn()) {
- UserService.doLogin();
- return null;
- }
-
const ability = defineAbility(() => {});
return (
diff --git a/spiffworkflow-frontend/src/ContainerForExtensions.tsx b/spiffworkflow-frontend/src/ContainerForExtensions.tsx
index b9382cbc..22eb8775 100644
--- a/spiffworkflow-frontend/src/ContainerForExtensions.tsx
+++ b/spiffworkflow-frontend/src/ContainerForExtensions.tsx
@@ -18,6 +18,7 @@ import HttpService from './services/HttpService';
import { ErrorBoundaryFallback } from './ErrorBoundaryFallack';
import BaseRoutes from './routes/BaseRoutes';
import BackendIsDown from './routes/BackendIsDown';
+import UserService from './services/UserService';
export default function ContainerForExtensions() {
const [backendIsUp, setBackendIsUp] = useState
(null);
@@ -93,6 +94,7 @@ export default function ContainerForExtensions() {
]);
const routeComponents = () => {
+ UserService.loginIfNeeded();
return (
('');
const { targetUris } = useUriListForPermissions();
-
- // App.jsx forces login (which redirects to keycloak) so we should never get here if we're not logged in.
- if (!UserService.isLoggedIn()) {
- throw new UnauthenticatedError('You must be authenticated to do this.');
- }
const permissionRequestData: PermissionsToCheck = {
[targetUris.authenticationListPath]: ['GET'],
[targetUris.messageInstanceListPath]: ['GET'],
@@ -99,12 +93,6 @@ export default function NavigationBar({ extensionUxElements }: OwnProps) {
return activeKey === menuItemPath;
};
- let aboutLinkElement = null;
-
- if (Object.keys(versionInfo).length) {
- aboutLinkElement = About ;
- }
-
const userEmail = UserService.getUserEmail();
const username = UserService.getPreferredUsername();
@@ -113,48 +101,56 @@ export default function NavigationBar({ extensionUxElements }: OwnProps) {
return {uxElement.label} ;
};
- const profileToggletip = (
-
-
-
- {username[0].toUpperCase()}
-
-
-
- {username}
-
- {username !== userEmail && {userEmail}
}
-
- {aboutLinkElement}
-
- Documentation
-
-
- {!UserService.authenticationDisabled() ? (
- <>
-
-
-
- Sign out
-
- >
- ) : null}
-
-
-
- );
+ const profileToggletip = () => {
+ let aboutLinkElement = null;
+
+ if (Object.keys(versionInfo).length) {
+ aboutLinkElement = About ;
+ }
+
+ return (
+
+
+
+ {username[0].toUpperCase()}
+
+
+
+ {username}
+
+ {username !== userEmail && {userEmail}
}
+
+ {aboutLinkElement}
+
+ Documentation
+
+
+ {!UserService.authenticationDisabled() ? (
+ <>
+
+
+
+ Sign out
+
+ >
+ ) : null}
+
+
+
+ );
+ };
const loginAndLogoutAction = () => {
if (UserService.isLoggedIn()) {
@@ -168,7 +164,7 @@ export default function NavigationBar({ extensionUxElements }: OwnProps) {
{SPIFF_ENVIRONMENT}
) : null}
- {profileToggletip}
+ {profileToggletip()}
>
);
}
@@ -292,6 +288,11 @@ export default function NavigationBar({ extensionUxElements }: OwnProps) {
);
};
+ // App.jsx forces login (which redirects to keycloak) so we should never get here if we're not logged in.
+ if (!UserService.isLoggedIn()) {
+ return null;
+ }
+
if (activeKey && ability && !UserService.onlyGuestTaskCompletion()) {
return (
{
);
};
-UserService.loginIfNeeded();
doRender();
// If you want to start measuring performance in your app, pass a function