Big cleanup and adding IdentityBuilder extensions the same way as the EF IdentityBuilder extensions do, allowing customer Identity setup.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
namespace AspNetCore.Identity.MongoDbCore.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// A class representing the claims a <see cref="MongoIdentityUser{TKey}"/> can have.
|
||||
/// </summary>
|
||||
public class MongoClaim
|
||||
{
|
||||
/// <summary>
|
||||
/// The type of the claim.
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
/// <summary>
|
||||
/// The value of the claim.
|
||||
/// </summary>
|
||||
public string Value { get; set; }
|
||||
/// <summary>
|
||||
/// The issuer of the claim.
|
||||
/// </summary>
|
||||
public string Issuer { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -3,32 +3,55 @@ using Microsoft.AspNetCore.Identity;
|
||||
using MongoDbGenericRepository.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace AspNetCore.Identity.MongoDbCore.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="MongoIdentityRole{TKey}"/> where TKey is a <see cref="string"/>
|
||||
/// </summary>
|
||||
public class MongoDbIdentityRole : MongoIdentityRole<string>
|
||||
{
|
||||
/// <summary>
|
||||
/// The constructor for a <see cref="MongoDbIdentityRole"/>
|
||||
/// </summary>
|
||||
public MongoDbIdentityRole() : base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constructor for a <see cref="MongoDbIdentityRole"/>, taking a role name.
|
||||
/// </summary>
|
||||
/// <param name="roleName">The name of the role.</param>
|
||||
public MongoDbIdentityRole(string roleName) : base(roleName)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="MongoIdentityRole{TKey}"/> where TKey is a <see cref="Guid"/>
|
||||
/// </summary>
|
||||
public class MongoIdentityRole : MongoIdentityRole<Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// The constructor for a <see cref="MongoIdentityRole"/>
|
||||
/// </summary>
|
||||
public MongoIdentityRole() : base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constructor for a <see cref="MongoIdentityRole"/>, taking a role name.
|
||||
/// </summary>
|
||||
/// <param name="roleName">The name of the role.</param>
|
||||
public MongoIdentityRole(string roleName) : base(roleName)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A document representing an <see cref="IdentityRole{TKey}"/> document.
|
||||
/// </summary>
|
||||
/// <typeparam name="TKey">The type of the primary key.</typeparam>
|
||||
public class MongoIdentityRole<TKey> : IdentityRole<TKey>, IDocument<TKey>, IClaimHolder
|
||||
where TKey : IEquatable<TKey>
|
||||
{
|
||||
@@ -53,17 +76,29 @@ namespace AspNetCore.Identity.MongoDbCore.Models
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constructor for a <see cref="MongoIdentityRole{TKey}"/>
|
||||
/// </summary>
|
||||
public MongoIdentityRole()
|
||||
{
|
||||
InitializeFields();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constructor for a <see cref="MongoIdentityRole{TKey}"/>, taking a role name.
|
||||
/// </summary>
|
||||
/// <param name="roleName">The name of the role.</param>
|
||||
public MongoIdentityRole(string roleName)
|
||||
{
|
||||
Name = roleName;
|
||||
InitializeFields();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constructor for a <see cref="MongoIdentityRole{TKey}"/>, taking a role name and a primary key value.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the role.</param>
|
||||
/// <param name="key">The value of the primary key</param>
|
||||
public MongoIdentityRole(string name, TKey key)
|
||||
{
|
||||
InitializeFields();
|
||||
|
||||
@@ -8,58 +8,62 @@ using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace AspNetCore.Identity.MongoDbCore.Models
|
||||
{
|
||||
public class Token
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the LoginProvider this token is from.
|
||||
/// </summary>
|
||||
public string LoginProvider { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the token.
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the token value.
|
||||
/// </summary>
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
public class MongoClaim {
|
||||
public string Type { get; set; }
|
||||
public string Value { get; set; }
|
||||
public string Issuer { get; set; }
|
||||
}
|
||||
|
||||
public class UserRole
|
||||
{
|
||||
public object UserId { get; set; }
|
||||
public object RoleId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="MongoIdentityUser{TKey}"/> where TKey is a <see cref="string"/>
|
||||
/// </summary>
|
||||
public class MongoDbIdentityUser : MongoIdentityUser<string>
|
||||
{
|
||||
/// <summary>
|
||||
/// The constructor for a <see cref="MongoDbIdentityUser"/>
|
||||
/// </summary>
|
||||
public MongoDbIdentityUser() : base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constructor for a <see cref="MongoDbIdentityUser"/>, taking a username.
|
||||
/// </summary>
|
||||
/// <param name="userName">The name of the user.</param>
|
||||
public MongoDbIdentityUser(string userName) : base(userName)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constructor for a <see cref="MongoDbIdentityUser"/>, taking a username and an email address.
|
||||
/// </summary>
|
||||
/// <param name="userName">The name of the user.</param>
|
||||
/// <param name="email">The email address of the user.</param>
|
||||
public MongoDbIdentityUser(string userName, string email) : base(userName, email)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="MongoIdentityUser{TKey}"/> where TKey is a <see cref="Guid"/>
|
||||
/// </summary>
|
||||
public class MongoIdentityUser : MongoIdentityUser<Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// The constructor for a <see cref="MongoIdentityUser"/>
|
||||
/// </summary>
|
||||
public MongoIdentityUser() : base()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constructor for a <see cref="MongoDbIdentityUser"/>, taking a username.
|
||||
/// </summary>
|
||||
/// <param name="userName">The name of the user.</param>
|
||||
public MongoIdentityUser(string userName) : base(userName)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The constructor for a <see cref="MongoDbIdentityUser"/>, taking a username and an email address.
|
||||
/// </summary>
|
||||
/// <param name="userName">The name of the user.</param>
|
||||
/// <param name="email">The email address of the user.</param>
|
||||
public MongoIdentityUser(string userName, string email) : base(userName, email)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace AspNetCore.Identity.MongoDbCore.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// A class representing the tokens a <see cref="MongoIdentityUser{TKey}"/> can have.
|
||||
/// </summary>
|
||||
public class Token
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the LoginProvider this token is from.
|
||||
/// </summary>
|
||||
public string LoginProvider { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the token.
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the token value.
|
||||
/// </summary>
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user