@@ -26,6 +26,30 @@ export const onboardOrganization = task({
2626 } ,
2727 data : { triggerJobId : null } ,
2828 } ) ;
29+
30+ try {
31+ logger . info (
32+ `Revalidating path ${ process . env . BETTER_AUTH_URL } /${ organizationId } ` ,
33+ ) ;
34+ const revalidateResponse = await axios . post (
35+ `${ process . env . BETTER_AUTH_URL } /api/revalidate/path` ,
36+ {
37+ path : `${ process . env . BETTER_AUTH_URL } /${ organizationId } ` ,
38+ secret : process . env . REVALIDATION_SECRET ,
39+ } ,
40+ ) ;
41+
42+ if ( ! revalidateResponse . data . ok ) {
43+ logger . error (
44+ `Failed to revalidate path: ${ revalidateResponse . statusText } ` ,
45+ ) ;
46+ logger . error ( revalidateResponse . data ) ;
47+ } else {
48+ logger . info ( "Revalidated path successfully" ) ;
49+ }
50+ } catch ( err ) {
51+ logger . error ( "Error revalidating path" , { err } ) ;
52+ }
2953 } ,
3054 run : async ( payload : {
3155 organizationId : string ;
@@ -244,27 +268,6 @@ export const onboardOrganization = task({
244268 data : { completed : true } ,
245269 } ) ;
246270
247- try {
248- const revalidateResponse = await axios . post (
249- `${ process . env . BETTER_AUTH_URL } /api/revalidate/path` ,
250- {
251- json : {
252- path : `${ process . env . BETTER_AUTH_URL } /${ payload . organizationId } ` ,
253- secret : process . env . REVALIDATION_SECRET ,
254- } ,
255- } ,
256- ) ;
257-
258- if ( ! revalidateResponse . data . ok ) {
259- logger . error (
260- `Failed to revalidate path: ${ revalidateResponse . statusText } ` ,
261- ) ;
262- logger . error ( revalidateResponse . data ) ;
263- }
264- } catch ( err ) {
265- logger . error ( "Error revalidating path" , { err } ) ;
266- }
267-
268271 logger . info ( `Created ${ extractRisks . object . risks . length } risks` ) ;
269272 logger . info ( `Created ${ extractVendors . object . vendors . length } vendors` ) ;
270273 } ,
0 commit comments