projects/spikersoft/src/app/_guards/role.guard.ts denies access by calling router.navigate(["/"]) and then returning false (two places, ~L24 and ~L36). That starts a second navigation from inside a running one (race-prone, and the original navigation is reported as cancelled rather than redirected). The router's supported way is to return a RedirectCommand (or UrlTree); Angular 22.2 additionally lets guards throw a RedirectCommand.
The guard also console.logs the user's realm roles and the grant/deny result on every guarded navigation.
What changes for us
Return type → Promise<boolean | RedirectCommand>; replace both navigate + false with return new RedirectCommand(router.parseUrl("/")) (consider skipLocationChange/replaceUrl so Back doesn't bounce).
Remove the three console.log lines (or route through the logging service at debug level).
Update role.guard specs (assert the returned redirect instead of a navigate spy).
Acceptance criteria
no router.navigate inside the guard; specs cover unauthenticated, missing role, granted
no role data logged to the console
Size: S. Returning RedirectCommand works today; the throw variant needs Angular 22.2.
Filed from the 2026-10-02 spikersoft-angular pnpm outdated changelog review.
## Why
`projects/spikersoft/src/app/_guards/role.guard.ts` denies access by calling `router.navigate(["/"])` and then returning `false` (two places, ~L24 and ~L36). That starts a second navigation from inside a running one (race-prone, and the original navigation is reported as cancelled rather than redirected). The router's supported way is to **return a `RedirectCommand`** (or `UrlTree`); Angular **22.2** additionally lets guards **throw** a `RedirectCommand`.
The guard also `console.log`s the user's realm roles and the grant/deny result on every guarded navigation.
## What changes for us
- Return type → `Promise<boolean | RedirectCommand>`; replace both `navigate + false` with `return new RedirectCommand(router.parseUrl("/"))` (consider `skipLocationChange`/`replaceUrl` so Back doesn't bounce).
- Remove the three `console.log` lines (or route through the logging service at debug level).
- Update `role.guard` specs (assert the returned redirect instead of a `navigate` spy).
## Acceptance criteria
- [ ] no `router.navigate` inside the guard; specs cover unauthenticated, missing role, granted
- [ ] no role data logged to the console
Size: **S**. Returning `RedirectCommand` works today; the *throw* variant needs Angular 22.2.
**Links:** Throw variant needs #1165.
---
_Filed from the 2026-10-02 spikersoft-angular `pnpm outdated` changelog review._
Checked against angular master (projects/spikersoft/src/app/_guards/role.guard.ts):
Redirect, no second navigation: there is no router.navigate left in the guard. It returns Promise<boolean | UrlTree> and denies with return router.parseUrl("/"). A returned UrlTree is the router's supported redirect, and it gives the same behaviour as RedirectCommand without extra options. The same fix was applied to parent, reading-interest and staff-or-parent guards.
No role logging: the guard has no console.log calls left.
Specs:role.guard.spec.ts covers an open route, an unauthenticated user, granted (any of the roles), denied (none of the roles), a token without realm_access (fails closed), and the wait for the #1363 auth probe.
The optional throw variant still needs Angular 22.2 (#1165). Nothing requires it, so I'm not keeping this open for it.
Side note, outside this ticket: auth.guard.ts still has 6 console.log lines. They log the route URL and the auth/refresh state, but no role data.
**Tracker sweep 2026-10-06. Closing: done by spikerj/spikersoft-angular#1417 (merged 2026-10-02, commit 3532af5a7).**
Checked against angular `master` (`projects/spikersoft/src/app/_guards/role.guard.ts`):
- **Redirect, no second navigation:** there is no `router.navigate` left in the guard. It returns `Promise<boolean | UrlTree>` and denies with `return router.parseUrl("/")`. A returned `UrlTree` is the router's supported redirect, and it gives the same behaviour as `RedirectCommand` without extra options. The same fix was applied to `parent`, `reading-interest` and `staff-or-parent` guards.
- **No role logging:** the guard has no `console.log` calls left.
- **Specs:** `role.guard.spec.ts` covers an open route, an unauthenticated user, granted (any of the roles), denied (none of the roles), a token without `realm_access` (fails closed), and the wait for the #1363 auth probe.
The optional *throw* variant still needs Angular 22.2 (#1165). Nothing requires it, so I'm not keeping this open for it.
Side note, outside this ticket: `auth.guard.ts` still has 6 `console.log` lines. They log the route URL and the auth/refresh state, but no role data.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Why
projects/spikersoft/src/app/_guards/role.guard.tsdenies access by callingrouter.navigate(["/"])and then returningfalse(two places, ~L24 and ~L36). That starts a second navigation from inside a running one (race-prone, and the original navigation is reported as cancelled rather than redirected). The router's supported way is to return aRedirectCommand(orUrlTree); Angular 22.2 additionally lets guards throw aRedirectCommand.The guard also
console.logs the user's realm roles and the grant/deny result on every guarded navigation.What changes for us
Promise<boolean | RedirectCommand>; replace bothnavigate + falsewithreturn new RedirectCommand(router.parseUrl("/"))(considerskipLocationChange/replaceUrlso Back doesn't bounce).console.loglines (or route through the logging service at debug level).role.guardspecs (assert the returned redirect instead of anavigatespy).Acceptance criteria
router.navigateinside the guard; specs cover unauthenticated, missing role, grantedSize: S. Returning
RedirectCommandworks today; the throw variant needs Angular 22.2.Links: Throw variant needs #1165.
Filed from the 2026-10-02 spikersoft-angular
pnpm outdatedchangelog review.Tracker sweep 2026-10-06. Closing: done by spikerj/spikersoft-angular#1417 (merged 2026-10-02, commit 3532af5a7).
Checked against angular
master(projects/spikersoft/src/app/_guards/role.guard.ts):router.navigateleft in the guard. It returnsPromise<boolean | UrlTree>and denies withreturn router.parseUrl("/"). A returnedUrlTreeis the router's supported redirect, and it gives the same behaviour asRedirectCommandwithout extra options. The same fix was applied toparent,reading-interestandstaff-or-parentguards.console.logcalls left.role.guard.spec.tscovers an open route, an unauthenticated user, granted (any of the roles), denied (none of the roles), a token withoutrealm_access(fails closed), and the wait for the #1363 auth probe.The optional throw variant still needs Angular 22.2 (#1165). Nothing requires it, so I'm not keeping this open for it.
Side note, outside this ticket:
auth.guard.tsstill has 6console.loglines. They log the route URL and the auth/refresh state, but no role data.