From e64380326fc65c26a514d2fd6b6446d031dfc6fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enes=20Sad=C4=B1k=20=C3=96zbek?= Date: Thu, 2 May 2019 00:58:52 +0300 Subject: [PATCH] Fix wrong returnUrl in callback --- src/ExternalLoginController.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ExternalLoginController.cs b/src/ExternalLoginController.cs index 4b13fe5..e6e04f7 100644 --- a/src/ExternalLoginController.cs +++ b/src/ExternalLoginController.cs @@ -9,6 +9,7 @@ using Microsoft.Extensions.Logging; namespace SteamOpenIdConnectProxy { [AllowAnonymous] + [Route("[action]")] public class ExternalLoginController : Controller { private readonly SignInManager _signInManager; @@ -27,30 +28,29 @@ namespace SteamOpenIdConnectProxy [HttpGet] - [Route("/ExternalLogin")] - public async Task Login(string returnUrl = null) + public async Task ExternalLogin(string returnUrl = null) { string provider = "Steam"; // Request a redirect to the external login provider. - var redirectUrl = "/ExternalLoginCallback?returnUrl=" + Uri.EscapeUriString(returnUrl); + var redirectUrl = Url.Action("ExternalLoginCallback", new { returnUrl }); var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl); return new ChallengeResult(provider, properties); } [HttpGet] - [Route("/ExternalLoginCallback")] - public async Task Callback(string returnUrl = null, string remoteError = null) + public async Task ExternalLoginCallback(string returnUrl = null, string remoteError = null) { returnUrl = returnUrl ?? Url.Content("~/"); if (remoteError != null) { - return Content($"Error from external provider: {remoteError}"); + throw new Exception($"Error from external provider: {remoteError}"); } + var info = await _signInManager.GetExternalLoginInfoAsync(); if (info == null) { - return Content($"Error loading external login information."); + throw new Exception($"Error loading external login information."); } // Sign in the user with this external login provider if the user already has a login.