Browse Source

Portal link fixed

pull/216/head
Sebastian Stehle 8 years ago
parent
commit
ec9bd33ab5
  1. 8
      src/Squidex/Areas/Portal/Middlewares/PortalDashboardAuthenticationMiddleware.cs
  2. 9
      src/Squidex/Areas/Portal/Middlewares/PortalRedirectMiddleware.cs
  3. 1
      src/Squidex/Config/Authentication/IdentityServerServices.cs

8
src/Squidex/Areas/Portal/Middlewares/PortalDashboardAuthenticationMiddleware.cs

@ -29,13 +29,17 @@ namespace Squidex.Areas.Portal.Middlewares
if (!authentication.Succeeded)
{
await context.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties
var properties = new AuthenticationProperties
{
RedirectUri = context.Request.PathBase + context.Request.Path
});
};
await context.ChallengeAsync(OpenIdConnectDefaults.AuthenticationScheme, properties);
}
else
{
context.User = authentication.Principal;
await next(context);
}
}

9
src/Squidex/Areas/Portal/Middlewares/PortalRedirectMiddleware.cs

@ -6,10 +6,10 @@
// All rights reserved.
// ==========================================================================
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Squidex.Domain.Apps.Entities.Apps.Services;
using Squidex.Infrastructure.Security;
namespace Squidex.Areas.Portal.Middlewares
{
@ -26,9 +26,12 @@ namespace Squidex.Areas.Portal.Middlewares
{
if (context.Request.Path == "/")
{
var userId = context.User.FindFirst(OpenIdClaims.Subject).Value;
var userIdClaim = context.User.FindFirst(ClaimTypes.NameIdentifier);
context.Response.RedirectToAbsoluteUrl(await appPlansBillingManager.GetPortalLinkAsync(userId));
if (userIdClaim != null)
{
context.Response.RedirectToAbsoluteUrl(await appPlansBillingManager.GetPortalLinkAsync(userIdClaim.Value));
}
}
}
}

1
src/Squidex/Config/Authentication/IdentityServerServices.cs

@ -51,6 +51,7 @@ namespace Squidex.Config.Authentication
options.ClientSecret = Constants.InternalClientSecret;
options.RequireHttpsMetadata = identityOptions.RequiresHttps;
options.SaveTokens = true;
options.Scope.Add(Constants.ProfileScope);
options.Scope.Add(Constants.RoleScope);
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
});

Loading…
Cancel
Save