@@ -48,16 +48,16 @@ export function useSsoAuth() {
4848 } ;
4949
5050 const disableFormOnSubmit = ( ) => {
51- const { form } = getInputFields ( ) ;
52- if ( form ) {
53- form . style . display = 'none' ;
51+ const fields = getInputFields ( ) ;
52+ if ( fields ?. form ) {
53+ fields . form . style . display = 'none' ;
5454 }
5555 } ;
5656
5757 const reEnableFormOnError = ( ) => {
58- const { form } = getInputFields ( ) ;
59- if ( form ) {
60- form . style . display = 'block' ;
58+ const fields = getInputFields ( ) ;
59+ if ( fields ?. form ) {
60+ fields . form . style . display = 'block' ;
6161 }
6262 } ;
6363
@@ -76,36 +76,37 @@ export function useSsoAuth() {
7676
7777 const handleOAuthCallback = async ( ) => {
7878 try {
79+ // First check hash parameters (for token and error - keeps them out of server logs)
80+ const hashParams = new URLSearchParams ( window . location . hash . slice ( 1 ) ) ;
81+ const hashToken = hashParams . get ( 'token' ) ;
82+ const hashError = hashParams . get ( 'error' ) ;
83+
84+ // Then check query parameters (for OAuth code/state from provider redirects)
7985 const search = new URLSearchParams ( window . location . search ) ;
8086 const code = search . get ( 'code' ) ?? '' ;
8187 const state = search . get ( 'state' ) ?? '' ;
82- const errorParam = search . get ( 'error' ) ?? '' ;
8388 const sessionState = getStateToken ( ) ;
8489
85- // Check for error parameter
90+ // Check for error in hash (preferred) or query params (fallback)
91+ const errorParam = hashError || search . get ( 'error' ) || '' ;
8692 if ( errorParam ) {
8793 currentState . value = 'error' ;
88- // Use the error parameter directly from the backend
8994 error . value = errorParam ;
9095
91- // Clean up the URL
92- const url = new URL ( window . location . href ) ;
93- url . searchParams . delete ( 'error' ) ;
94- window . history . replaceState ( { } , document . title , url . pathname + url . search ) ;
96+ // Clean up the URL (both hash and query params)
97+ window . history . replaceState ( { } , document . title , window . location . pathname ) ;
9598 return ;
9699 }
97100
98- // Handle OAuth callback if we have a token (from OIDC redirect)
99- const token = search . get ( 'token' ) ;
101+ // Handle OAuth callback if we have a token in hash (from OIDC redirect)
102+ const token = hashToken || search . get ( 'token' ) ; // Check hash first, query as fallback
100103 if ( token ) {
101104 currentState . value = 'loading' ;
102105 disableFormOnSubmit ( ) ;
103106 enterCallbackTokenIntoField ( token ) ;
104107
105- // Clean up the URL
106- const url = new URL ( window . location . href ) ;
107- url . searchParams . delete ( 'token' ) ;
108- window . history . replaceState ( { } , document . title , url . pathname ) ;
108+ // Clean up the URL (both hash and query params)
109+ window . history . replaceState ( { } , document . title , window . location . pathname ) ;
109110 return ;
110111 }
111112
0 commit comments