Skip to content

Commit 00f36a4

Browse files
author
Lasim
committed
feat(gateway): enhance whoami command to display additional user info
1 parent ff97ec0 commit 00f36a4

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

services/gateway/src/commands/whoami.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,22 @@ export function registerWhoamiCommand(program: Command) {
3535

3636
const api = new DeployStackAPI(credentials, backendUrl);
3737

38-
// Get user info
38+
// Get fresh user info from the API (real-time verification)
3939
const userInfo = await api.getUserInfo();
4040
const tokenInfo = await api.getTokenInfo();
4141
const accounts = api.getUserAccounts();
4242

4343
// Display user information
44-
const userEmail = userInfo.email || api.getUserEmail();
44+
const userEmail = userInfo.email;
4545
console.log(chalk.blue(`👋 You are logged in with an OAuth Token, associated with ${userEmail}`));
46+
console.log(chalk.gray(`🆔 User ID (sub): ${userInfo.sub}`));
47+
if (userInfo.name) {
48+
console.log(chalk.gray(`👤 Full Name: ${userInfo.name}`));
49+
}
50+
if (userInfo.preferred_username) {
51+
console.log(chalk.gray(`🏷️ Username: ${userInfo.preferred_username}`));
52+
}
53+
console.log(chalk.gray(`✅ Email Verified: ${userInfo.email_verified ? 'Yes' : 'No'}`));
4654
console.log(chalk.gray(`🌐 Using backend: ${backendUrl}\n`));
4755

4856
// Display account info in table format if accounts exist

services/gateway/src/core/auth/api-client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export class DeployStackAPI {
1212
}
1313

1414
/**
15-
* Get authenticated user information
15+
* Get authenticated user information from the backend API
16+
* Makes a real-time API call to /api/oauth2/userinfo to verify token validity
17+
* and retrieve fresh user information including sub, email, name, etc.
1618
* @returns User information
1719
*/
1820
async getUserInfo(): Promise<UserInfo> {

services/gateway/src/types/auth.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ export interface StoredCredentials {
1313
export interface UserInfo {
1414
sub: string;
1515
email: string;
16-
name: string;
17-
preferred_username: string;
16+
name?: string;
17+
preferred_username?: string;
1818
email_verified: boolean;
19+
given_name?: string;
20+
family_name?: string;
1921
}
2022

2123
export interface TokenResponse {

0 commit comments

Comments
 (0)