Browse Source

Update the Mvc.Server sample to use the default entity key type

pull/237/head
Kévin Chalet 9 years ago
parent
commit
dde3dc1aca
  1. 5
      samples/Mvc.Server/Controllers/AuthorizationController.cs
  2. 2
      samples/Mvc.Server/Models/ApplicationDbContext.cs
  3. 2
      samples/Mvc.Server/Models/ApplicationUser.cs
  4. 10
      samples/Mvc.Server/Startup.cs

5
samples/Mvc.Server/Controllers/AuthorizationController.cs

@ -4,7 +4,6 @@
* the license and the contributors participating to this project.
*/
using System;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
@ -22,12 +21,12 @@ using OpenIddict;
namespace Mvc.Server {
public class AuthorizationController : Controller {
private readonly OpenIddictApplicationManager<OpenIddictApplication<Guid>> _applicationManager;
private readonly OpenIddictApplicationManager<OpenIddictApplication> _applicationManager;
private readonly SignInManager<ApplicationUser> _signInManager;
private readonly UserManager<ApplicationUser> _userManager;
public AuthorizationController(
OpenIddictApplicationManager<OpenIddictApplication<Guid>> applicationManager,
OpenIddictApplicationManager<OpenIddictApplication> applicationManager,
SignInManager<ApplicationUser> signInManager,
UserManager<ApplicationUser> userManager) {
_applicationManager = applicationManager;

2
samples/Mvc.Server/Models/ApplicationDbContext.cs

@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore;
using OpenIddict;
namespace Mvc.Server.Models {
public class ApplicationDbContext : OpenIddictDbContext<ApplicationUser, IdentityRole<Guid>, Guid> {
public class ApplicationDbContext : OpenIddictDbContext<ApplicationUser, IdentityRole> {
public ApplicationDbContext(DbContextOptions options)
: base(options) { }

2
samples/Mvc.Server/Models/ApplicationUser.cs

@ -3,5 +3,5 @@ using OpenIddict;
namespace Mvc.Server.Models {
// Add profile data for application users by adding properties to the ApplicationUser class
public class ApplicationUser : OpenIddictUser<Guid> { }
public class ApplicationUser : OpenIddictUser { }
}

10
samples/Mvc.Server/Startup.cs

@ -25,12 +25,12 @@ namespace Mvc.Server {
options.UseSqlServer(configuration["Data:DefaultConnection:ConnectionString"]));
// Register the Identity services.
services.AddIdentity<ApplicationUser, IdentityRole<Guid>>()
.AddEntityFrameworkStores<ApplicationDbContext, Guid>()
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
// Register the OpenIddict services, including the default Entity Framework stores.
services.AddOpenIddict<ApplicationDbContext, Guid>()
services.AddOpenIddict<ApplicationDbContext>()
// Register the ASP.NET Core MVC binder used by OpenIddict.
// Note: if you don't call this method, you won't be able to
// bind OpenIdConnectRequest or OpenIdConnectResponse parameters.
@ -149,7 +149,7 @@ namespace Mvc.Server {
// Type = OpenIddictConstants.ClientTypes.Confidential
// });
context.Applications.Add(new OpenIddictApplication<Guid> {
context.Applications.Add(new OpenIddictApplication {
ClientId = "myClient",
ClientSecret = Crypto.HashPassword("secret_secret_secret"),
DisplayName = "My client application",
@ -167,7 +167,7 @@ namespace Mvc.Server {
// * Scope: openid email profile roles
// * Grant type: authorization code
// * Request access token locally: yes
context.Applications.Add(new OpenIddictApplication<Guid> {
context.Applications.Add(new OpenIddictApplication {
ClientId = "postman",
DisplayName = "Postman",
RedirectUri = "https://www.getpostman.com/oauth2/callback",

Loading…
Cancel
Save