()
| 62 | // Initialize device flow session, copy code, and open browser |
| 63 | useEffect(() => { |
| 64 | const initializeDeviceFlow = async () => { |
| 65 | try { |
| 66 | const scopes = |
| 67 | scopeChoice === 'public' |
| 68 | ? getAlternateScopeNames() |
| 69 | : getRecommendedScopeNames(); |
| 70 | |
| 71 | const newSession = await loginWithDeviceFlowStart( |
| 72 | reAuthAccount?.hostname, |
| 73 | scopes, |
| 74 | ); |
| 75 | setSession(newSession); |
| 76 | |
| 77 | // Auto-copy the user code to clipboard |
| 78 | await copyToClipboard(newSession.userCode); |
| 79 | |
| 80 | // Auto-open the verification URL in the browser |
| 81 | openExternalLink(newSession.verificationUri as Link); |
| 82 | } catch (err) { |
| 83 | rendererLogError( |
| 84 | 'LoginWithDeviceFlow', |
| 85 | 'Failed to start device flow', |
| 86 | toError(err), |
| 87 | ); |
| 88 | setError('Failed to start authentication. Please try again.'); |
| 89 | } |
| 90 | }; |
| 91 | |
| 92 | if (scopeChoice) { |
| 93 | initializeDeviceFlow(); |
no test coverage detected