Skip to content

Commit fbfe553

Browse files
committed
Added newtonsoft JSON
1 parent b314ca8 commit fbfe553

5 files changed

Lines changed: 15 additions & 8 deletions

File tree

src/IdentityManager2/Api/Controllers/PageController.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ public PageController(IdentityManagerOptions config)
2121

2222
[HttpGet]
2323
[Route("", Name = IdentityManagerConstants.RouteNames.Home)]
24-
public IActionResult Index()
24+
public async Task<IActionResult> Index()
2525
{
26+
var authResult = await HttpContext.AuthenticateAsync(config.SecurityConfiguration.HostAuthenticationType);
27+
2628
return View("/Areas/IdentityManager/Pages/Index.cshtml", new PageModel
2729
{
2830
PathBase = Request.PathBase,
2931
Model = JsonConvert.SerializeObject(new
3032
{
3133
PathBase = Request.PathBase,
32-
ShowLoginButton = User.Identity.IsAuthenticated
34+
ShowLoginButton = !authResult.Succeeded
3335
})
3436
});
3537
}
@@ -39,10 +41,10 @@ public IActionResult Index()
3941
[Route("api/login", Name = IdentityManagerConstants.RouteNames.Login)]
4042
public async Task<IActionResult> Login(string returnUrl)
4143
{
42-
var result = await HttpContext.AuthenticateAsync(config.SecurityConfiguration.HostAuthenticationType);
43-
if (result.Succeeded)
44+
var authResult = await HttpContext.AuthenticateAsync(config.SecurityConfiguration.HostAuthenticationType);
45+
if (authResult.Succeeded)
4446
{
45-
await HttpContext.SignInAsync(IdentityManagerConstants.LocalApiScheme, result.Principal);
47+
await HttpContext.SignInAsync(IdentityManagerConstants.LocalApiScheme, authResult.Principal);
4648
return Redirect(returnUrl);
4749
}
4850

src/IdentityManager2/Api/Controllers/UsersController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
namespace IdentityManager2.Api.Controllers
1717
{
1818
[Route(IdentityManagerConstants.UserRoutePrefix)]
19-
[Authorize(IdentityManagerConstants.IdMgrAuthPolicy)] // TODO: Ensure schemes configurable (e.g. re-add OAuth)
19+
[Authorize(IdentityManagerConstants.IdMgrAuthPolicy)]
2020
[ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)]
2121
public class UsersController : Controller
2222
{

src/IdentityManager2/Assets/Scripts/Bundle.js

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/IdentityManager2/Configuration/DependencyInjection/IdentityManagerServiceCollectionExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public static IIdentityManagerBuilder AddIdentityManager(this IServiceCollection
2525

2626
var builder = services.AddIdentityManagerBuilder();
2727

28-
builder.Services.AddControllersWithViews();
28+
builder.Services.AddControllersWithViews()
29+
.AddNewtonsoftJson();
2930

3031
builder.Services.AddOptions();
3132
builder.Services.AddSingleton(identityManagerOptions);

src/IdentityManager2/IdentityManager2.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<ItemGroup>
5353
<FrameworkReference Include="Microsoft.AspNetCore.App" />
5454
<PackageReference Include="AutoMapper" Version="9.0.0" />
55+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0" />
5556
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
5657
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
5758
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="3.1.0" />

0 commit comments

Comments
 (0)