Skip to content

Commit

Permalink
Add preferred_username and use that for WS creation
Browse files Browse the repository at this point in the history
  • Loading branch information
iyannsch committed Nov 2, 2024
1 parent d6a912e commit 6b7df36
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion node/landing-page/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function App(): JSX.Element {
const [selectedAppDefinition, setSelectedAppDefinition] = useState<string>(initialAppDefinition);

const [email, setEmail] = useState<string>();
const [username, setUsername] = useState<string>();
const [token, setToken] = useState<string>();
const [logoutUrl, setLogoutUrl] = useState<string>();

Expand Down Expand Up @@ -132,7 +133,10 @@ function App(): JSX.Element {
const userMail = parsedToken.email;
setToken(keycloak.idToken);
setEmail(userMail);
setUsername(parsedToken['preferred_username'] ?? userMail);
setLogoutUrl(keycloak.createLogoutUrl());
console.log('Authenticated as ' + parsedToken.preferred_username + '(' + userMail + ')');
console.log('parsedToken', parsedToken);
}
}
})
Expand Down Expand Up @@ -192,7 +196,10 @@ function App(): JSX.Element {
const userMail = parsedToken.email;
setToken(keycloak.idToken);
setEmail(userMail);
setUsername(parsedToken['preferred_username'] ?? userMail);
setLogoutUrl(keycloak.createLogoutUrl());
console.log('Authenticated as ' + parsedToken.preferred_username + '(' + userMail + ')');
console.log('parsedToken', parsedToken);
}
}
})
Expand All @@ -216,7 +223,9 @@ function App(): JSX.Element {
// First we split at the / character, get the last part, split at the - character and get the first part
const repoName = gitUri ? gitUri?.split('/').pop()?.split('-')[0] : Math.random().toString().substring(2, 10);

const workspace = 'ws-' + config.appId + '-' + selectedAppDefinition + '-' + repoName + '-' + email;
const workspace = config.useEphemeralStorage
? undefined
: 'ws-' + selectedAppDefinition + '-' + repoName + '-' + username;

const requestOptions: RequestOptions = {
timeout: 60000,
Expand Down

0 comments on commit 6b7df36

Please sign in to comment.