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 1, 2024
1 parent d6a912e commit 76c25e7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 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,9 @@ 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 ' + username + '(' + userMail + ')');
}
}
})
Expand Down Expand Up @@ -192,7 +195,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 ' + username + '(' + userMail + ')');
console.log(parsedToken);
}
}
})
Expand All @@ -216,7 +222,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 76c25e7

Please sign in to comment.