From 936e184ba932fce75b379eeb6e197af0648aac68 Mon Sep 17 00:00:00 2001 From: kevin Date: Fri, 6 Oct 2023 16:42:00 -0600 Subject: [PATCH] fix(controller/finder): altering the beforeFind middleware to ensure redirection is blocked --- packages/snap-controller/src/Finder/FinderController.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/snap-controller/src/Finder/FinderController.ts b/packages/snap-controller/src/Finder/FinderController.ts index 7638ecc60..d663ff603 100644 --- a/packages/snap-controller/src/Finder/FinderController.ts +++ b/packages/snap-controller/src/Finder/FinderController.ts @@ -63,12 +63,6 @@ export class FinderController extends AbstractController { finder.controller.store.loading = false; }); - this.eventManager.on('beforeFind', async (finder: { controller: FinderController }, next: Next): Promise => { - await next(); - - window.location.href = this.urlManager.href; - }); - // attach config plugins and event middleware this.use(this.config); @@ -115,6 +109,9 @@ export class FinderController extends AbstractController { await this.eventManager.fire('beforeFind', { controller: this, }); + + // redirect to configured URL after middleware completes + window.location.href = this.urlManager.href; } catch (err: any) { if (err?.message == 'cancelled') { this.log.warn(`'beforeFind' middleware cancelled`);