-
Notifications
You must be signed in to change notification settings - Fork 380
Expand file tree
/
Copy pathsignin.ts
More file actions
30 lines (27 loc) · 965 Bytes
/
signin.ts
File metadata and controls
30 lines (27 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { AuthenticationProviderTobikoCloud } from '../auth/auth'
import * as vscode from 'vscode'
import { isCodespaces } from '../utilities/isCodespaces'
import { traceInfo } from '../utilities/common/log'
export const signIn =
(
authenticationProvider: AuthenticationProviderTobikoCloud,
onSignInSuccess: () => Promise<void>,
) =>
async () => {
if (isCodespaces()) {
await authenticationProvider.sign_in_device_flow()
} else {
await authenticationProvider.createSession()
}
// Do not await this, as this will block the thread, you just need to show the message, but not block
vscode.window.showInformationMessage('Signed in successfully')
// Execute callback after successful sign-in
if (onSignInSuccess) {
traceInfo('Executing post sign-in callback')
try {
await onSignInSuccess()
} catch (error) {
traceInfo(`Error in post sign-in callback: ${error}`)
}
}
}