Skip to content

Commit

Permalink
Sign in before redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-dudarev committed Jul 23, 2024
1 parent c16259d commit 33a1a9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,13 @@ public async Task<ActionResult> SignOut(string authenticationType)
[AllowAnonymous]
public async Task<ActionResult> SignInCallback(string returnUrl)
{
if (!Url.IsLocalUrl(returnUrl))
{
return Redirect(GetHomeUrl());
}

var signInResult = await _externalSignInService.SignInAsync();

return signInResult.Success
? Redirect(returnUrl)
: Redirect(GetHomeUrl());
var redirectUrl = signInResult.Success && Url.IsLocalUrl(returnUrl)
? returnUrl
: GetHomeUrl();

return Redirect(redirectUrl);
}

[HttpGet]
Expand Down
11 changes: 2 additions & 9 deletions src/VirtoCommerce.Platform.Web/Security/ExternalSignInService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,11 @@ public ExternalSignInService(
[Obsolete("Not being called. Use SignInAsync()", DiagnosticId = "VC0009", UrlFormat = "https://docs.virtocommerce.org/products/products-virto3-versions/")]
public virtual async Task<string> ProcessCallbackAsync(string returnUrl, IUrlHelper urlHelper)
{
var homeUrl = urlHelper.Action("Index", "Home") ?? "/";

if (!urlHelper.IsLocalUrl(returnUrl))
{
return homeUrl;
}

var signInResult = await SignInAsync();

return signInResult.Success
return signInResult.Success && urlHelper.IsLocalUrl(returnUrl)
? returnUrl
: homeUrl;
: urlHelper.Action("Index", "Home") ?? "/";
}

public virtual async Task<ExternalSignInResult> SignInAsync()
Expand Down

0 comments on commit 33a1a9f

Please sign in to comment.