@@ -37,30 +37,17 @@ const handleCallback = (req: Request, res: Response) => {
3737 }
3838 }
3939
40- // The rest of the validation for redirect_url for other error types or success.
41- // This redirect_url is specific to the application's own flow, not the OAuth callback itself initially.
42- const receivedRedirectUrl = req . session . postLoginRedirectUrl ;
43- delete req . session . postLoginRedirectUrl ;
4440 const allowedFrontendUrls = ( process . env . FRONTEND_WEBSITE_URLS || '' )
4541 . split ( ',' )
4642 . map ( ( url ) => url . trim ( ) )
4743 . filter ( ( url ) => url . length > 0 ) ;
4844
49- let frontendBaseUrl : string ;
45+ const frontendBaseUrl = allowedFrontendUrls [ 0 ] ;
5046
51- if ( receivedRedirectUrl && allowedFrontendUrls . includes ( receivedRedirectUrl ) ) {
52- frontendBaseUrl = receivedRedirectUrl ;
53- } else {
54- Logger . warn (
55- `Invalid or missing redirect_url: '${ receivedRedirectUrl } '. Allowed: ${ allowedFrontendUrls . join ( ', ' ) } `
56- ) ;
57- if ( allowedFrontendUrls . length > 0 ) {
58- frontendBaseUrl = allowedFrontendUrls [ 0 ] ; // Default to the first allowed URL
59- } else {
60- // This is a server misconfiguration or critical error if no allowed URLs are configured.
61- Logger . error ( 'CRITICAL: No FRONTEND_WEBSITE_URLS configured for redirection.' ) ;
62- return sendErrorResponse ( res , 400 , 'Invalid redirect URL specified or application misconfigured.' ) ;
63- }
47+ if ( ! frontendBaseUrl ) {
48+ // This is a server misconfiguration or critical error if no allowed URLs are configured.
49+ Logger . error ( 'CRITICAL: No FRONTEND_WEBSITE_URLS configured for redirection.' ) ;
50+ return sendErrorResponse ( res , 400 , 'Invalid redirect URL specified or application misconfigured.' ) ;
6451 }
6552
6653 // Handle cases where the provider indicates an error (e.g., user denied access)
@@ -172,11 +159,6 @@ const handleLogout = (req: Request, res: Response) => {
172159 * @returns github authorization url
173160 */
174161const handleGitHubLogin = ( req : Request , res : Response ) => {
175- const redirectAfter = req . query . redirect_after as string | undefined ;
176- if ( redirectAfter ) {
177- req . session . postLoginRedirectUrl = redirectAfter ;
178- }
179-
180162 // generate a random state
181163 const state = randomBytes ( 16 ) . toString ( 'hex' ) ;
182164 req . session . oAuthState = state ;
0 commit comments