@@ -37,30 +37,17 @@ const handleCallback = (req: Request, res: Response) => {
37
37
}
38
38
}
39
39
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 ;
44
40
const allowedFrontendUrls = ( process . env . FRONTEND_WEBSITE_URLS || '' )
45
41
. split ( ',' )
46
42
. map ( ( url ) => url . trim ( ) )
47
43
. filter ( ( url ) => url . length > 0 ) ;
48
44
49
- let frontendBaseUrl : string ;
45
+ const frontendBaseUrl = allowedFrontendUrls [ 0 ] ;
50
46
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.' ) ;
64
51
}
65
52
66
53
// Handle cases where the provider indicates an error (e.g., user denied access)
@@ -172,11 +159,6 @@ const handleLogout = (req: Request, res: Response) => {
172
159
* @returns github authorization url
173
160
*/
174
161
const 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
-
180
162
// generate a random state
181
163
const state = randomBytes ( 16 ) . toString ( 'hex' ) ;
182
164
req . session . oAuthState = state ;
0 commit comments