From 06905b23c5232c6ef26a52c4e6c0093d014f3f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Sun, 26 Jul 2020 18:38:27 +0200 Subject: [PATCH] Update the Mvc.Server sample to reference MongoDB --- .../Controllers/AuthorizationController.cs | 14 ++++++-------- samples/Mvc.Server/Mvc.Server.csproj | 1 + samples/Mvc.Server/Startup.cs | 5 +++++ samples/Mvc.Server/Worker.cs | 6 ++---- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/samples/Mvc.Server/Controllers/AuthorizationController.cs b/samples/Mvc.Server/Controllers/AuthorizationController.cs index 775664cb..2dda9912 100644 --- a/samples/Mvc.Server/Controllers/AuthorizationController.cs +++ b/samples/Mvc.Server/Controllers/AuthorizationController.cs @@ -20,8 +20,6 @@ using Mvc.Server.Helpers; using Mvc.Server.Models; using Mvc.Server.ViewModels.Authorization; using OpenIddict.Abstractions; -using OpenIddict.Core; -using OpenIddict.EntityFrameworkCore.Models; using OpenIddict.Server.AspNetCore; using static OpenIddict.Abstractions.OpenIddictConstants; @@ -29,16 +27,16 @@ namespace Mvc.Server { public class AuthorizationController : Controller { - private readonly OpenIddictApplicationManager _applicationManager; - private readonly OpenIddictAuthorizationManager _authorizationManager; - private readonly OpenIddictScopeManager _scopeManager; + private readonly IOpenIddictApplicationManager _applicationManager; + private readonly IOpenIddictAuthorizationManager _authorizationManager; + private readonly IOpenIddictScopeManager _scopeManager; private readonly SignInManager _signInManager; private readonly UserManager _userManager; public AuthorizationController( - OpenIddictApplicationManager applicationManager, - OpenIddictAuthorizationManager authorizationManager, - OpenIddictScopeManager scopeManager, + IOpenIddictApplicationManager applicationManager, + IOpenIddictAuthorizationManager authorizationManager, + IOpenIddictScopeManager scopeManager, SignInManager signInManager, UserManager userManager) { diff --git a/samples/Mvc.Server/Mvc.Server.csproj b/samples/Mvc.Server/Mvc.Server.csproj index 014e3762..dbfe1de7 100644 --- a/samples/Mvc.Server/Mvc.Server.csproj +++ b/samples/Mvc.Server/Mvc.Server.csproj @@ -9,6 +9,7 @@ + diff --git a/samples/Mvc.Server/Startup.cs b/samples/Mvc.Server/Startup.cs index 79df37e6..9050302e 100644 --- a/samples/Mvc.Server/Startup.cs +++ b/samples/Mvc.Server/Startup.cs @@ -55,6 +55,11 @@ namespace Mvc.Server // Note: call ReplaceDefaultEntities() to replace the default OpenIddict entities. options.UseEntityFrameworkCore() .UseDbContext(); + + // Developers who prefer using MongoDB can remove the previous lines + // and configure OpenIddict to use the specified MongoDB database: + // options.UseMongoDb() + // .UseDatabase(new MongoClient().GetDatabase("openiddict")); }) // Register the OpenIddict server components. diff --git a/samples/Mvc.Server/Worker.cs b/samples/Mvc.Server/Worker.cs index c9e99996..5a72bf8d 100644 --- a/samples/Mvc.Server/Worker.cs +++ b/samples/Mvc.Server/Worker.cs @@ -5,8 +5,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Mvc.Server.Models; using OpenIddict.Abstractions; -using OpenIddict.Core; -using OpenIddict.EntityFrameworkCore.Models; using static OpenIddict.Abstractions.OpenIddictConstants; namespace Mvc.Server @@ -30,7 +28,7 @@ namespace Mvc.Server static async Task RegisterApplicationsAsync(IServiceProvider provider) { - var manager = provider.GetRequiredService>(); + var manager = provider.GetRequiredService(); if (await manager.FindByClientIdAsync("mvc") == null) { @@ -106,7 +104,7 @@ namespace Mvc.Server static async Task RegisterScopesAsync(IServiceProvider provider) { - var manager = provider.GetRequiredService>(); + var manager = provider.GetRequiredService(); if (await manager.FindByNameAsync("demo_api") == null) {