I have some code like this
ngOnInit(): void {
this.activatedRoute.url.subscribe(() => {
const token = this.activatedRoute.snapshot.queryParamMap.get('token');
const redirectPage = this.activatedRoute.snapshot.queryParamMap.get('redirectPage');
if (token) {
localStorage.setItem(AuthenticationStorageKey, token);
if (redirectPage) {
this.router.navigate([redirectPage]);
} else {
this.router.navigate(['']);
}
} else {
this.router.navigate([`/error/404`]);
}
});
}
What I does not like is that I have too many IF and ELSE, anybody knows some better solution, thanks?