How to use aurelia-router - 10 common examples

To help you get started, we’ve selected a few aurelia-router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aurelia-contrib / aurelia-open-id-connect / test / open-id-connect-authorize-step.spec.ts View on Github external
it(`should redirect to ${unauthRedirectRoute} if user is null`, async () => {
        // arrange
        (userManager.getUser).returns(null);
        // act
        await authorizationStep.run(navigationInstruction, next);
        // assert
        sinon.assert.calledWith(next.cancel, new Redirect(unauthRedirectRoute));
      });
github aurelia-contrib / aurelia-open-id-connect / test / open-id-connect-authorize-step.spec.ts View on Github external
it(`redirect should be to the unauthorized route with original URL as LoginRedirect parameter`, async () => {
        // arrange
        (userManager.getUser).returns(null);
        // act
        await authorizationStep.run(navigationInstruction, next);
        // assert
        sinon.assert.calledWith(next.cancel, new Redirect(expectedRedirect));
      });
github thollingshead / arcgis-server-store / src / components / store-settings.js View on Github external
canActivate() {
		// Don't show as router-view if sidebar is not hidden
		return window.innerWidth < config.SCREEN_SMALL_BREAKPOINT_PX || new Redirect('');
	}
github aurelia-contrib / aurelia-open-id-connect / src / open-id-connect-authorize-step.ts View on Github external
// TODO: Make this open for extension,
    // so that user-land can configure multiple, arbitrary roles.
    if (this.requiresRole(navigationInstruction, OpenIdConnectRoles.Authenticated)) {
      if (user === null || user.expired) {
        this.logger.debug('Requires authenticated role.');

        // capture the URL to which the user was originally navigating
        // include that URL in a query string parameter on the redirect
        let loginRedirect = navigationInstruction.fragment;
        if (navigationInstruction.queryString && navigationInstruction.queryString.length) {
          loginRedirect += `?${navigationInstruction.queryString}`;
        }
        const loginRedirectValue = encodeURIComponent(loginRedirect);
        const queryString = `?${LoginRedirectKey}=${loginRedirectValue}`;
        const redirect = new Redirect(this.configuration.unauthorizedRedirectRoute + queryString);

        return next.cancel(redirect);
      }
    }

    return next();
  }
github adarshpastakia / aurelia-ui-framework / src / utils / ui-application.ts View on Github external
run(routingContext, next) {
    // Check if the route has an "auth" key
    // The reason for using `nextInstructions` is because this includes child routes.
    if (routingContext.getAllInstructions()
      .some(i => i.config.auth)) {
      if (!this.appState.Authenticated) {
        this.logger.warn('Not authenticated');
        let url = routingContext.router.generate('login', { status: 401 });
        this.appState.Authenticated = false;
        this.appState.session('AppCurrentRoute', [routingContext.config.route, routingContext.params]);
        this.appState.session('AppCurrentFragment', routingContext.fragment);
        return next.reject(new Redirect(url));
      }
    }

    return next();
  }
}
github adarshpastakia / aurelia-ui-framework / src / resources / utils / ui-application.ts View on Github external
run(routingContext, next) {
    // Check if the route has an "auth" key
    // The reason for using `nextInstructions` is because this includes child routes.
    if (routingContext.getAllInstructions()
      .some(i => i.config.auth)) {
      if (!this.appState.Authenticated) {
        this.logger.warn('Not authenticated');
        let url = routingContext.router.generate('login', { status: 401 });
        this.appState.Authenticated = false;
        this.appState.session('AppCurrentRoute', [routingContext.config.route, routingContext.params]);
        this.appState.session('AppCurrentFragment', routingContext.fragment);
        return next.reject(new Redirect(url));
      }
    }

    return next();
  }
}
github sigmaframeworks / sigma-ui-framework / src / resources / utils / ui-application.ts View on Github external
run(routingContext, next) {
    // Check if the route has an "auth" key
    // The reason for using `nextInstructions` is because this includes child routes.
    if (routingContext.getAllInstructions()
      .some(i => i.config.auth)) {
      if (!this.appState.IsAuthenticated) {
        this.logger.warn('Not authenticated');
        let url = routingContext.router.generate('login', { status: 401 });
        this.appState.IsAuthenticated = false;
        this.appState.session('AppCurrentRoute', [routingContext.config.route, routingContext.params]);
        this.appState.session('AppCurrentFragment', routingContext.fragment);
        return next.reject(new Redirect(url));
      }
    }

    return next();
  }
}
github process-engine / bpmn-studio / src / modules / design / processdef-detail / processdef-detail.ts View on Github external
resolve(false);
          });
        }
        //#endregion
    });

    const result: boolean = await _modal;

    // TODO: Extract Business Rule
    if (result === false) {
      /*
       * As suggested in https://github.com/aurelia/router/issues/302, we use
       * the router directly to navigate back, which results in staying on this
       * component-- and this is the desired behaviour.
       */
      return new Redirect(this._router.currentInstruction.fragment, {trigger: false, replace: false});
    }
  }
github paulvanbladel / aurelia-auth / dist / es6 / authorizeStep.js View on Github external
run(routingContext, next) {
    var isLoggedIn = this.auth.isAuthenticated();
    var loginRoute = this.auth.getLoginRoute();

    if (routingContext.getAllInstructions().some(i => i.config.auth)) {
      if (!isLoggedIn) {
        this.auth.setInitialUrl(window.location.href);
        return next.cancel(new Redirect(loginRoute));
      }
    } else if (isLoggedIn && routingContext.getAllInstructions().some(i => i.fragment == loginRoute)) {
      var loginRedirect = this.auth.getLoginRedirect();
      return next.cancel(new Redirect(loginRedirect));
    }

    return next();
  }
}
github paulvanbladel / aurelia-auth / src / authorizeStep.js View on Github external
run(routingContext, next) {
    var isLoggedIn = this.auth.isAuthenticated();
    var loginRoute = this.auth.getLoginRoute();

    if (routingContext.getAllInstructions().some(i => i.config.auth)) {
      if (!isLoggedIn) {
        this.auth.setInitialUrl(window.location.href);
        return next.cancel(new Redirect(loginRoute));
      }
    } else if (isLoggedIn && routingContext.getAllInstructions().some(i => i.fragment == loginRoute)) {
      var loginRedirect = this.auth.getLoginRedirect();
      return next.cancel(new Redirect(loginRedirect));
    }

    return next();
  }
}

aurelia-router

A powerful client-side router.

MIT
Latest version published 5 years ago

Package Health Score

56 / 100
Full package analysis

Popular aurelia-router functions