Skip to content

Commit 9aa37e7

Browse files
Merge pull request #39 from docusign/DEVDOCS-16961
Devdocs 16961
2 parents 8de19a9 + 0b51f42 commit 9aa37e7

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

DocuSign.MyAPI/ClientApp/src/app/core/errorhandler.inteceptor.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,13 @@ export class ErrorHanlderInterceptor implements HttpInterceptor {
4242
let snackBarRef = this.notificationService.showInfo(res);
4343

4444
snackBarRef.afterDismissed().subscribe(() => {
45+
let returnUrl = this.router.url;
46+
// Only allow relative paths
47+
if (!returnUrl.startsWith('/')) {
48+
returnUrl = '/';
49+
}
4550
window.location.href =
46-
'/account/login?returnUrl=' + this.router.url;
51+
'/account/login?returnUrl=' + returnUrl;
4752
});
4853
});
4954
}

DocuSign.MyAPI/ClientApp/src/app/header/header.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ export class AppHeaderComponent implements OnInit {
1919
ngOnInit(): void {
2020
this.router.events.subscribe((event) => {
2121
if (event instanceof NavigationEnd) {
22-
this.url = this.router.url;
22+
let currentUrl = this.router.url;
23+
// Only allow relative paths
24+
if (currentUrl.startsWith('/')) {
25+
this.url = currentUrl;
26+
} else {
27+
this.url = '/';
28+
}
2329
}
2430
});
2531
}

DocuSign.MyAPI/Controllers/AccountController.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public async Task<ActionResult<String>> GetAccountId()
2727
[Route("login")]
2828
public IActionResult Login(string returnUrl = "/")
2929
{
30+
if (string.IsNullOrEmpty(returnUrl) || !Url.IsLocalUrl(returnUrl))
31+
{
32+
returnUrl = "/";
33+
}
34+
3035
return Challenge(new AuthenticationProperties() { RedirectUri = returnUrl, AllowRefresh = true });
3136
}
3237

0 commit comments

Comments
 (0)