Skip to content

Commit

Permalink
refactor(): update redirect guard
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony133 committed Jul 16, 2023
1 parent 18258e7 commit 7c736fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const routes: Routes = [
preloadingStrategy: PreloadAllModules,
}),
],
providers: [RedirectGuard],
providers: [],
exports: [RouterModule],
})
export class AppRoutingModule {}
20 changes: 8 additions & 12 deletions src/app/shared/guards/redirect.guard.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import { Injectable } from '@angular/core';
import {
ActivatedRouteSnapshot,
CanActivate,
CanActivateFn,
RouterStateSnapshot,
} from '@angular/router';

@Injectable()
export class RedirectGuard implements CanActivate {
canActivate(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot,
): boolean {
window.location.href = route.data['externalUrl'];
return true;
}
}
export const RedirectGuard: CanActivateFn = (
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot,
) => {
window.location.href = route.data['externalUrl'];
return true;
};

0 comments on commit 7c736fe

Please sign in to comment.