Skip to content

Commit 9aba0d4

Browse files
Merge pull request #6933 from GeorgiZhelev/fix/find-session-by-alias-or-userid
Fix --alias to also match by userId for UUID-aliased sessions
2 parents cb018ff + 3e2b6b4 commit 9aba0d4

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

packages/cli-kit/src/private/node/session/store.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,17 @@ describe('session store', () => {
178178
expect(result).toBeUndefined()
179179
})
180180

181+
test('returns userId when alias matches userId directly', async () => {
182+
// Given
183+
vi.mocked(getSessions).mockReturnValue(JSON.stringify(mockSessions))
184+
185+
// When
186+
const result = await findSessionByAlias('user1')
187+
188+
// Then
189+
expect(result).toBe('user1')
190+
})
191+
181192
test('returns first matching userId when multiple sessions have same alias', async () => {
182193
// Given
183194
const sessionsWithDuplicateAlias = {

packages/cli-kit/src/private/node/session/store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export async function findSessionByAlias(alias: string): Promise<string | undefi
7171
if (!fqdnSessions) return undefined
7272

7373
for (const [userId, session] of Object.entries(fqdnSessions)) {
74-
if (session.identity.alias === alias) {
74+
if (session.identity.alias === alias || userId === alias) {
7575
return userId
7676
}
7777
}

0 commit comments

Comments
 (0)