Skip to content

Commit

Permalink
Add more logic to authenticate the user before launching the appDef
Browse files Browse the repository at this point in the history
  • Loading branch information
iyannsch committed Oct 29, 2024
1 parent 97e6c64 commit 0ad1af7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions node/landing-page/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Loading } from './components/Loading';
import { LoginButton } from './components/LoginButton';

// global state to be kept between render calls
let initialized = false;
const [initialized, setInitialized] = useState(false);
let initialAppName = '';
let initialAppDefinition = '';
let keycloakConfig: KeycloakConfig | undefined = undefined;
Expand Down Expand Up @@ -124,14 +124,15 @@ function App(): JSX.Element {
setToken(keycloak.idToken);
setEmail(userMail);
setLogoutUrl(keycloak.createLogoutUrl());
setInitialized(true);
}
}
})
.catch(() => {
console.error('Authentication Failed');
setError('Authentication failed');
});
}
initialized = true;
}

useEffect(() => {
Expand All @@ -150,8 +151,7 @@ function App(): JSX.Element {
}

if (selectedAppDefinition && gitUri) {
console.log('Checking auth, setting autoStart to true and starting session');
authenticate();
console.log('Setting autoStart to true and starting session');
setAutoStart(true);
handleStartSession(selectedAppDefinition);
} else {
Expand Down Expand Up @@ -197,6 +197,7 @@ function App(): JSX.Element {
setLoading(true);
setError(undefined);


// first check if the service is available. if not we are doing maintenance and should adapt the error message accordingly
TheiaCloud.ping(PingRequest.create(config.serviceUrl, config.appId))
.then(() => {
Expand Down Expand Up @@ -296,6 +297,7 @@ function App(): JSX.Element {
'Sorry, we are performing some maintenance at the moment.\n' +
"Please try again later. Usually maintenance won't last longer than 60 minutes.\n\n"
);
setError(_err.message);
setLoading(false);
});
};
Expand Down

0 comments on commit 0ad1af7

Please sign in to comment.