Browse Source

Remove OpenIddictUser

pull/243/head
Kévin Chalet 9 years ago
parent
commit
bc5f21ad26
  1. 5
      samples/Mvc.Server/Models/ApplicationUser.cs
  2. 1
      samples/Mvc.Server/Startup.cs
  3. 42
      src/OpenIddict.EntityFramework/Models/OpenIddictUser.cs
  4. 23
      src/OpenIddict.EntityFramework/OpenIddictDbContext.cs

5
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 { }
}

1
samples/Mvc.Server/Startup.cs

@ -1,4 +1,3 @@
using System;
using System.Linq;
using CryptoHelper;
using Microsoft.AspNetCore.Builder;

42
src/OpenIddict.EntityFramework/Models/OpenIddictUser.cs

@ -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 {
/// <summary>
/// Represents an OpenIddict user.
/// </summary>
public class OpenIddictUser : OpenIddictUser<string, OpenIddictAuthorization, OpenIddictToken> {
public OpenIddictUser() {
// Generate a new string identifier.
Id = Guid.NewGuid().ToString();
}
}
/// <summary>
/// Represents an OpenIddict user.
/// </summary>
public class OpenIddictUser<TKey> : OpenIddictUser<TKey, OpenIddictAuthorization<TKey>, OpenIddictToken<TKey>>
where TKey : IEquatable<TKey> { }
/// <summary>
/// Represents an OpenIddict user.
/// </summary>
public class OpenIddictUser<TKey, TAuthorization, TToken> : IdentityUser<TKey> where TKey : IEquatable<TKey> {
/// <summary>
/// Gets the list of the authorizations associated with this user profile.
/// </summary>
public virtual IList<TAuthorization> Authorizations { get; } = new List<TAuthorization>();
/// <summary>
/// Gets the list of the tokens associated with this user profile.
/// </summary>
public virtual IList<TToken> Tokens { get; } = new List<TToken>();
}
}

23
src/OpenIddict.EntityFramework/OpenIddictDbContext.cs

@ -12,7 +12,7 @@ namespace OpenIddict {
/// <summary>
/// Represents an OpenIddict-powered Entity Framework context.
/// </summary>
public class OpenIddictDbContext : OpenIddictDbContext<OpenIddictUser> {
public class OpenIddictDbContext : OpenIddictDbContext<IdentityUser> {
/// <summary>
/// Initializes a new OpenIddict context without configuring the Entity Framework options.
/// </summary>
@ -33,7 +33,7 @@ namespace OpenIddict {
OpenIddictAuthorization,
OpenIddictScope,
OpenIddictToken, string>
where TUser : OpenIddictUser {
where TUser : IdentityUser {
/// <summary>
/// Initializes a new OpenIddict context without configuring the Entity Framework options.
/// </summary>
@ -55,7 +55,7 @@ namespace OpenIddict {
OpenIddictAuthorization,
OpenIddictScope,
OpenIddictToken, string>
where TUser : OpenIddictUser
where TUser : IdentityUser
where TRole : IdentityRole {
/// <summary>
/// Initializes a new OpenIddict context without configuring the Entity Framework options.
@ -79,7 +79,7 @@ namespace OpenIddict {
OpenIddictAuthorization<TKey>,
OpenIddictScope<TKey>,
OpenIddictToken<TKey>, TKey>
where TUser : OpenIddictUser<TKey>
where TUser : IdentityUser<TKey>
where TRole : IdentityRole<TKey>
where TKey : IEquatable<TKey> {
/// <summary>
@ -105,7 +105,7 @@ namespace OpenIddict {
/// <typeparam name="TToken">The type of the Token entity.</typeparam>
/// <typeparam name="TKey">The type of the primary key used by the Identity/OpenIddict entities.</typeparam>
public class OpenIddictDbContext<TUser, TRole, TApplication, TAuthorization, TScope, TToken, TKey> : IdentityDbContext<TUser, TRole, TKey>
where TUser : OpenIddictUser<TKey, TAuthorization, TToken>
where TUser : IdentityUser<TKey>
where TRole : IdentityRole<TKey>
where TApplication : OpenIddictApplication<TKey, TToken>
where TAuthorization : OpenIddictAuthorization<TKey, TToken>
@ -194,19 +194,6 @@ namespace OpenIddict {
entity.ToTable("OpenIddictTokens");
});
// Configure the TUser entity.
builder.Entity<TUser>(entity => {
entity.HasMany(user => user.Authorizations)
.WithOne()
.HasForeignKey("UserId")
.IsRequired(required: false);
entity.HasMany(user => user.Tokens)
.WithOne()
.HasForeignKey("UserId")
.IsRequired(required: false);
});
}
}
}
Loading…
Cancel
Save