-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redirect to original URL after login (#244)
- Loading branch information
Showing
7 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
authority-portal-frontend/src/app/core/global-state/routes/url-before-login.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import {Injectable} from '@angular/core'; | ||
import {NavigationEnd, Router} from '@angular/router'; | ||
import {filter, first, tap} from 'rxjs'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class UrlBeforeLoginService { | ||
public originalUrl: string = ''; | ||
|
||
constructor(private router: Router) { | ||
this.router.events | ||
.pipe( | ||
filter( | ||
(event): event is NavigationEnd => | ||
event instanceof NavigationEnd && | ||
event.url != null && | ||
event.url != undefined && | ||
event.url != '' && | ||
event.url != '/' && | ||
event.url != '/random-redirect-for-force-refresh', | ||
), | ||
first(), | ||
) | ||
.subscribe((event) => { | ||
this.originalUrl = event.urlAfterRedirects || event.url; | ||
localStorage.setItem('originalUrl', this.originalUrl); | ||
}); | ||
} | ||
|
||
public reset(): void { | ||
this.originalUrl = ''; | ||
} | ||
|
||
public goToOriginalUrl(): void { | ||
if (this.originalUrl) { | ||
this.router.navigateByUrl(this.originalUrl); | ||
this.reset(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters