Quantcast
Channel: User Simon_Weaver - Stack Overflow
Viewing all articles
Browse latest Browse all 116

Answer by Simon_Weaver for Angular 2 AuthGuard Service with redirect?

$
0
0

You can now return a UrlTree from an AuthGuard, or a boolean true / false.

Kind of amazed nobody has mentioned this yet

Example:

export const requireAuthGuard: CanActivateFn = () => {  const router = inject(Router);  return /*user is logged in*/    ? true    : router.createUrlTree(['/Login'])}

Viewing all articles
Browse latest Browse all 116

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>