11import { type FC , useCallback , useState } from 'react' ;
2- import { useNavigate } from 'react-router-dom' ;
2+ import { useLocation , useNavigate } from 'react-router-dom' ;
33
44import {
55 BookIcon ,
@@ -27,7 +27,13 @@ import { Page } from '../components/layout/Page';
2727import { Footer } from '../components/primitives/Footer' ;
2828import { Header } from '../components/primitives/Header' ;
2929
30- import type { ClientID , ClientSecret , Hostname , Token } from '../types' ;
30+ import type {
31+ Account ,
32+ ClientID ,
33+ ClientSecret ,
34+ Hostname ,
35+ Token ,
36+ } from '../types' ;
3137import type { LoginOAuthWebOptions } from '../utils/auth/types' ;
3238
3339import {
@@ -39,6 +45,10 @@ import {
3945import { openExternalLink } from '../utils/comms' ;
4046import { rendererLogError } from '../utils/logger' ;
4147
48+ interface LocationState {
49+ account ?: Account ;
50+ }
51+
4252export interface IFormData {
4353 hostname : Hostname ;
4454 clientId : ClientID ;
@@ -78,14 +88,16 @@ export const validateForm = (values: IFormData): IFormErrors => {
7888
7989export const LoginWithOAuthAppRoute : FC = ( ) => {
8090 const navigate = useNavigate ( ) ;
91+ const location = useLocation ( ) ;
92+ const { account : reAuthAccount } = ( location . state ?? { } ) as LocationState ;
8193
8294 const { loginWithOAuthApp } = useAppContext ( ) ;
8395
8496 const [ shouldMaskClientSecret , setShouldMaskClientSecret ] = useState ( true ) ;
8597 const [ isVerifyingCredentials , setIsVerifyingCredentials ] = useState ( false ) ;
8698
8799 const [ formData , setFormData ] = useState ( {
88- hostname : Constants . GITHUB_HOSTNAME ,
100+ hostname : reAuthAccount ?. hostname ?? Constants . GITHUB_HOSTNAME ,
89101 clientId : '' as ClientID ,
90102 clientSecret : '' as ClientSecret ,
91103 } as IFormData ) ;
0 commit comments