From bc5f21ad26714fc486de73c9df6634aaff0a038d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Wed, 19 Oct 2016 21:08:42 +0200 Subject: [PATCH] Remove OpenIddictUser --- samples/Mvc.Server/Models/ApplicationUser.cs | 5 +-- samples/Mvc.Server/Startup.cs | 1 - .../Models/OpenIddictUser.cs | 42 ------------------- .../OpenIddictDbContext.cs | 23 +++------- 4 files changed, 7 insertions(+), 64 deletions(-) delete mode 100644 src/OpenIddict.EntityFramework/Models/OpenIddictUser.cs diff --git a/samples/Mvc.Server/Models/ApplicationUser.cs b/samples/Mvc.Server/Models/ApplicationUser.cs index 19c02c98..7a885488 100644 --- a/samples/Mvc.Server/Models/ApplicationUser.cs +++ b/samples/Mvc.Server/Models/ApplicationUser.cs @@ -1,7 +1,6 @@ -using System; -using OpenIddict; +using Microsoft.AspNetCore.Identity.EntityFrameworkCore; namespace Mvc.Server.Models { // Add profile data for application users by adding properties to the ApplicationUser class - public class ApplicationUser : OpenIddictUser { } + public class ApplicationUser : IdentityUser { } } diff --git a/samples/Mvc.Server/Startup.cs b/samples/Mvc.Server/Startup.cs index 3196bc12..ebb38ecc 100644 --- a/samples/Mvc.Server/Startup.cs +++ b/samples/Mvc.Server/Startup.cs @@ -1,4 +1,3 @@ -using System; using System.Linq; using CryptoHelper; using Microsoft.AspNetCore.Builder; diff --git a/src/OpenIddict.EntityFramework/Models/OpenIddictUser.cs b/src/OpenIddict.EntityFramework/Models/OpenIddictUser.cs deleted file mode 100644 index 86b55ee0..00000000 --- a/src/OpenIddict.EntityFramework/Models/OpenIddictUser.cs +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0) - * See https://github.com/openiddict/openiddict-core for more information concerning - * the license and the contributors participating to this project. - */ - -using System; -using System.Collections.Generic; -using Microsoft.AspNetCore.Identity.EntityFrameworkCore; - -namespace OpenIddict { - /// - /// Represents an OpenIddict user. - /// - public class OpenIddictUser : OpenIddictUser { - public OpenIddictUser() { - // Generate a new string identifier. - Id = Guid.NewGuid().ToString(); - } - } - - /// - /// Represents an OpenIddict user. - /// - public class OpenIddictUser : OpenIddictUser, OpenIddictToken> - where TKey : IEquatable { } - - /// - /// Represents an OpenIddict user. - /// - public class OpenIddictUser : IdentityUser where TKey : IEquatable { - /// - /// Gets the list of the authorizations associated with this user profile. - /// - public virtual IList Authorizations { get; } = new List(); - - /// - /// Gets the list of the tokens associated with this user profile. - /// - public virtual IList Tokens { get; } = new List(); - } -} diff --git a/src/OpenIddict.EntityFramework/OpenIddictDbContext.cs b/src/OpenIddict.EntityFramework/OpenIddictDbContext.cs index 26f1d7cf..70be59fb 100644 --- a/src/OpenIddict.EntityFramework/OpenIddictDbContext.cs +++ b/src/OpenIddict.EntityFramework/OpenIddictDbContext.cs @@ -12,7 +12,7 @@ namespace OpenIddict { /// /// Represents an OpenIddict-powered Entity Framework context. /// - public class OpenIddictDbContext : OpenIddictDbContext { + public class OpenIddictDbContext : OpenIddictDbContext { /// /// Initializes a new OpenIddict context without configuring the Entity Framework options. /// @@ -33,7 +33,7 @@ namespace OpenIddict { OpenIddictAuthorization, OpenIddictScope, OpenIddictToken, string> - where TUser : OpenIddictUser { + where TUser : IdentityUser { /// /// Initializes a new OpenIddict context without configuring the Entity Framework options. /// @@ -55,7 +55,7 @@ namespace OpenIddict { OpenIddictAuthorization, OpenIddictScope, OpenIddictToken, string> - where TUser : OpenIddictUser + where TUser : IdentityUser where TRole : IdentityRole { /// /// Initializes a new OpenIddict context without configuring the Entity Framework options. @@ -79,7 +79,7 @@ namespace OpenIddict { OpenIddictAuthorization, OpenIddictScope, OpenIddictToken, TKey> - where TUser : OpenIddictUser + where TUser : IdentityUser where TRole : IdentityRole where TKey : IEquatable { /// @@ -105,7 +105,7 @@ namespace OpenIddict { /// The type of the Token entity. /// The type of the primary key used by the Identity/OpenIddict entities. public class OpenIddictDbContext : IdentityDbContext - where TUser : OpenIddictUser + where TUser : IdentityUser where TRole : IdentityRole where TApplication : OpenIddictApplication where TAuthorization : OpenIddictAuthorization @@ -194,19 +194,6 @@ namespace OpenIddict { entity.ToTable("OpenIddictTokens"); }); - - // Configure the TUser entity. - builder.Entity(entity => { - entity.HasMany(user => user.Authorizations) - .WithOne() - .HasForeignKey("UserId") - .IsRequired(required: false); - - entity.HasMany(user => user.Tokens) - .WithOne() - .HasForeignKey("UserId") - .IsRequired(required: false); - }); } } } \ No newline at end of file