Browse Source

Merge pull request #2670 from gterdem/pr/2519

EnablePostSignOutAutoRedirect = true
pull/2691/head
Halil İbrahim Kalkan 7 years ago
committed by GitHub
parent
commit
fb7b04a19c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Authentication/ChallengeAccountController.cs
  2. 44
      modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLogoutModel.cs
  3. 1
      modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/LogoutController.cs
  4. 3
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Logout.cshtml
  5. 27
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Logout.cshtml.cs

11
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Authentication/ChallengeAccountController.cs

@ -8,10 +8,12 @@ namespace Volo.Abp.AspNetCore.Mvc.Authentication
public abstract class ChallengeAccountController : AbpController
{
protected string[] ChallengeAuthenticationSchemas { get; }
protected string AuthenticationType { get; }
protected ChallengeAccountController(string[] challengeAuthenticationSchemas = null)
{
ChallengeAuthenticationSchemas = challengeAuthenticationSchemas ?? new[]{ "oidc" };
ChallengeAuthenticationSchemas = challengeAuthenticationSchemas ?? new[] { "oidc" };
AuthenticationType = "Identity.Application";
}
[HttpGet]
@ -42,7 +44,12 @@ namespace Volo.Abp.AspNetCore.Mvc.Authentication
{
await HttpContext.SignOutAsync().ConfigureAwait(false);
return RedirectSafely(returnUrl, returnUrlHash);
if (HttpContext.User.Identity.AuthenticationType == AuthenticationType)
{
return RedirectSafely(returnUrl, returnUrlHash);
}
return new SignOutResult(ChallengeAuthenticationSchemas);
}
protected RedirectResult RedirectSafely(string returnUrl, string returnUrlHash = null)

44
modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLogoutModel.cs

@ -0,0 +1,44 @@
using IdentityServer4.Services;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Account.Web.Pages.Account
{
[ExposeServices(typeof(LogoutModel))]
public class IdentityServerSupportedLogoutModel : LogoutModel
{
protected IIdentityServerInteractionService Interaction { get; }
public IdentityServerSupportedLogoutModel(IIdentityServerInteractionService interaction)
{
Interaction = interaction;
}
public override async Task<IActionResult> OnGetAsync()
{
await SignInManager.SignOutAsync().ConfigureAwait(false);
var logoutId = Request.Query["logoutId"].ToString();
if (!string.IsNullOrEmpty(logoutId))
{
var logoutContext = await Interaction.GetLogoutContextAsync(logoutId).ConfigureAwait(false);
var postLogoutUri = logoutContext.PostLogoutRedirectUri;
if (!string.IsNullOrEmpty(postLogoutUri))
{
return Redirect(postLogoutUri);
}
}
if (ReturnUrl != null)
{
return LocalRedirect(ReturnUrl);
}
return RedirectToPage("/Account/Login");
}
}
}

1
modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/LogoutController.cs

@ -17,6 +17,7 @@ namespace Volo.Abp.Account.Web.Areas.Account.Controllers
}
//todo@alper: this method can be moved to AccountController like "account/logout"
//No longer needed. Already implemented Pages/Account/Logout
public async Task<IActionResult> Index(string returnUrl = null)
{
await _signInManager.SignOutAsync().ConfigureAwait(false);

3
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Logout.cshtml

@ -0,0 +1,3 @@
@page "/Account/Logout"
@inherits Volo.Abp.Account.Web.Pages.Account.AccountPage
@model Volo.Abp.Account.Web.Pages.Account.LogoutModel

27
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Logout.cshtml.cs

@ -0,0 +1,27 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace Volo.Abp.Account.Web.Pages.Account
{
public class LogoutModel : AccountPageModel
{
[HiddenInput]
[BindProperty(SupportsGet = true)]
public string ReturnUrl { get; set; }
[HiddenInput]
[BindProperty(SupportsGet = true)]
public string ReturnUrlHash { get; set; }
public virtual async Task<IActionResult> OnGetAsync()
{
await SignInManager.SignOutAsync().ConfigureAwait(false);
if (ReturnUrl != null)
{
return RedirectSafely(ReturnUrl, ReturnUrlHash);
}
return RedirectToPage("/Account/Login");
}
}
}
Loading…
Cancel
Save