You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.5 KiB
40 lines
1.5 KiB
using System.Data.Entity;
|
|
using System.Security.Claims;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNet.Identity;
|
|
using Microsoft.AspNet.Identity.EntityFramework;
|
|
|
|
namespace OpenIddict.Sandbox.AspNet.Server.Models
|
|
{
|
|
// Vous pouvez ajouter des données de profil pour l'utilisateur en ajoutant d'autres propriétés à votre classe ApplicationUser. Pour en savoir plus, consultez https://go.microsoft.com/fwlink/?LinkID=317594.
|
|
public class ApplicationUser : IdentityUser
|
|
{
|
|
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
|
|
{
|
|
// Notez que l'authenticationType doit correspondre à celui défini dans CookieAuthenticationOptions.AuthenticationType
|
|
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
|
|
// Ajouter des revendications utilisateur personnalisées ici
|
|
return userIdentity;
|
|
}
|
|
}
|
|
|
|
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
|
|
{
|
|
public ApplicationDbContext()
|
|
: base("DefaultConnection", throwIfV1Schema: false)
|
|
{
|
|
}
|
|
|
|
public static ApplicationDbContext Create()
|
|
{
|
|
return new ApplicationDbContext();
|
|
}
|
|
|
|
protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
|
{
|
|
base.OnModelCreating(modelBuilder);
|
|
|
|
modelBuilder.UseOpenIddict();
|
|
}
|
|
}
|
|
}
|