mirror of https://github.com/abpframework/abp
parent
fd016c759c
commit
fbe0ad3f49
@ -0,0 +1,2 @@
|
||||
# abp-account
|
||||
Account module for ABP framework.
|
||||
@ -0,0 +1,16 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Version>0.3.0</Version>
|
||||
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||
<PackageIconUrl>http://www.aspnetboilerplate.com/images/abp_nupkg.png</PackageIconUrl>
|
||||
<PackageProjectUrl>http://abp.io</PackageProjectUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://github.com/volosoft/abp/</RepositoryUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.8.1" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,15 @@
|
||||
{
|
||||
"culture": "en",
|
||||
"texts": {
|
||||
"UserName": "User name",
|
||||
"EmailAddress": "Email address",
|
||||
"UserNameOrEmailAddress": "User name or email address",
|
||||
"Password": "Password",
|
||||
"RememberMe": "Remember me",
|
||||
"UseAnotherServiceToLogin": "Use another service to log in",
|
||||
"UserLockedOutMessage": "The user account has been locked out due to invalid login attempts. Please wait a while and try again.",
|
||||
"InvalidUserNameOrPassword": "Invalid username or password!",
|
||||
"LoginIsNotAllowed": "You are not allowed to login! You need to confirm your email/phone number.",
|
||||
"SelfRegistrationDisabledMessage": "Self user registration is disabled for this application. Contact to the application administrator to register a new user."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
@page
|
||||
@model Volo.Abp.Account.Web.Pages.Account.LoginModel
|
||||
@using Volo.Abp.Account.Web.Settings
|
||||
@inherits Volo.Abp.Account.Web.Pages.Account.AccountPage
|
||||
@inject Volo.Abp.Settings.ISettingManager SettingManager
|
||||
<h2>@L["Login"]</h2>
|
||||
<abp-row>
|
||||
<abp-column size-md="_3">
|
||||
<form method="post">
|
||||
<abp-input asp-for="Input.UserNameOrEmailAddress" auto-focus="true" />
|
||||
<abp-input asp-for="Input.Password" />
|
||||
<abp-input asp-for="Input.RememberMe" class="mb-3" />
|
||||
<abp-button button-type="Primary" type="submit">@L["Login"]</abp-button>
|
||||
@if (string.Equals(await SettingManager.GetOrNullAsync(AccountSettingNames.IsSelfRegistrationEnabled), "true", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
<a abp-button="Secondary" href="@Url.Page("./Register", new {returnUrl = Model.ReturnUrl, returnUrlHash = Model.ReturnUrlHash})">@L["Register"]</a>
|
||||
}
|
||||
</form>
|
||||
</abp-column>
|
||||
|
||||
@if (Model.ExternalLogins.Any())
|
||||
{
|
||||
<abp-column size-md="_3">
|
||||
<h4>Use another service to log in.</h4>
|
||||
<form asp-page="./Login" asp-page-handler="ExternalLogin" asp-route-returnUrl="@Model.ReturnUrl" asp-route-returnUrlHash="@Model.ReturnUrlHash" method="post">
|
||||
<div>
|
||||
@foreach (var provider in Model.ExternalLogins)
|
||||
{
|
||||
<abp-button button-type="Primary" type="submit" name="provider" value="@provider.Name">@provider.DisplayName</abp-button>
|
||||
}
|
||||
</div>
|
||||
</form>
|
||||
</abp-column>
|
||||
}
|
||||
|
||||
</abp-row>
|
||||
@ -0,0 +1,14 @@
|
||||
@page
|
||||
@model Volo.Abp.Account.Web.Pages.Account.RegisterModel
|
||||
@inherits Volo.Abp.Account.Web.Pages.Account.AccountPage
|
||||
<h2>@L["Register"]</h2>
|
||||
<abp-row>
|
||||
<abp-column size-md="_3">
|
||||
<form method="post">
|
||||
<abp-input asp-for="Input.UserName" auto-focus="true" />
|
||||
<abp-input asp-for="Input.EmailAddress" />
|
||||
<abp-input asp-for="Input.Password" />
|
||||
<abp-button button-type="Primary" type="submit">@L["Register"]</abp-button>
|
||||
</form>
|
||||
</abp-column>
|
||||
</abp-row>
|
||||
@ -0,0 +1,6 @@
|
||||
@page
|
||||
@using Volo.Abp.Account.Web.Pages.Account
|
||||
@inherits AccountPage
|
||||
@model SendSecurityCodeModel
|
||||
<h2>Send security code!</h2>
|
||||
<p>TODO: This page is under construction.</p>
|
||||
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
|
||||
namespace Volo.Abp.Account.Web.Pages.Account
|
||||
{
|
||||
public class SendSecurityCodeModel : AccountPageModel
|
||||
{
|
||||
public List<SelectListItem> Providers { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
var user = await SignInManager.GetTwoFactorAuthenticationUserAsync();
|
||||
if (user == null)
|
||||
{
|
||||
return RedirectToPage("./Login");
|
||||
}
|
||||
|
||||
return Page();
|
||||
|
||||
//CheckCurrentTenant(await SignInManager.GetVerifiedTenantIdAsync());
|
||||
|
||||
//Providers = (await UserManager.GetValidTwoFactorProvidersAsync(user))
|
||||
// .Select(userProvider =>
|
||||
// new SelectListItem
|
||||
// {
|
||||
// Text = userProvider,
|
||||
// Value = userProvider
|
||||
// }).ToList();
|
||||
|
||||
//return View(
|
||||
// new SendSecurityCodeViewModel
|
||||
// {
|
||||
// ReturnUrl = returnUrl,
|
||||
// RememberMe = rememberMe
|
||||
// }
|
||||
//);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap
|
||||
@ -0,0 +1,27 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:56009/",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Volo.Abp.Account.Web": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "http://localhost:56013/"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
# abp-identity
|
||||
Microsoft ASP.NET Core Identity integration & management module
|
||||
@ -0,0 +1,16 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Version>0.3.0</Version>
|
||||
<NoWarn>$(NoWarn);CS1591</NoWarn>
|
||||
<PackageIconUrl>http://www.aspnetboilerplate.com/images/abp_nupkg.png</PackageIconUrl>
|
||||
<PackageProjectUrl>http://abp.io</PackageProjectUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://github.com/volosoft/abp/</RepositoryUrl>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.8.1" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,12 @@
|
||||
{
|
||||
"culture": "en",
|
||||
"texts": {
|
||||
"Permission:IdentityManagement": "Idetity management",
|
||||
"Permission:RoleManagement": "Role management",
|
||||
"Permission:Create": "Create",
|
||||
"Permission:Edit": "Edit",
|
||||
"Permission:Delete": "Delete",
|
||||
"Permission:ChangePermissions": "Change permissions",
|
||||
"Permission:UserManagement": "User management"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<AssemblyName>Volo.Abp.Identity.Domain.Shared</AssemblyName>
|
||||
<PackageId>Volo.Abp.Identity.Domain.Shared</PackageId>
|
||||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
|
||||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
|
||||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
|
||||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
|
||||
<RootNamespace />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\abp-users\src\Volo.Abp.Users.Domain.Shared\Volo.Abp.Users.Domain.Shared.csproj" />
|
||||
|
||||
<ProjectReference Include="..\..\..\abp\src\Volo.Abp.Localization\Volo.Abp.Localization.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp71</s:String></wpf:ResourceDictionary>
|
||||
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
|
||||
namespace Volo.Abp.Identity
|
||||
{
|
||||
public interface IIdentityRoleRepository : IBasicRepository<IdentityRole, Guid>
|
||||
{
|
||||
Task<IdentityRole> FindByNormalizedNameAsync(
|
||||
string normalizedRoleName,
|
||||
bool includeDetails = true,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
Task<List<IdentityRole>> GetListAsync(
|
||||
string sorting = null,
|
||||
int maxResultCount = int.MaxValue,
|
||||
int skipCount = 0,
|
||||
bool includeDetails = false,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
Task<long> GetCountAsync(
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Security.Claims;
|
||||
using JetBrains.Annotations;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Guids;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
|
||||
namespace Volo.Abp.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a role in the identity system
|
||||
/// </summary>
|
||||
public class IdentityRole : AggregateRoot<Guid>, IHasConcurrencyStamp, IMultiTenant
|
||||
{
|
||||
public virtual Guid? TenantId { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name for this role.
|
||||
/// </summary>
|
||||
public virtual string Name { get; protected internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the normalized name for this role.
|
||||
/// </summary>
|
||||
public virtual string NormalizedName { get; protected internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Navigation property for claims in this role.
|
||||
/// </summary>
|
||||
public virtual ICollection<IdentityRoleClaim> Claims { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// A random value that should change whenever a role is persisted to the store
|
||||
/// </summary>
|
||||
public virtual string ConcurrencyStamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="IdentityRole"/>.
|
||||
/// </summary>
|
||||
protected IdentityRole() { }
|
||||
|
||||
public IdentityRole(Guid id, [NotNull] string name, Guid? tenantId = null)
|
||||
{
|
||||
Check.NotNull(name, nameof(name));
|
||||
|
||||
Id = id;
|
||||
Name = name;
|
||||
TenantId = tenantId;
|
||||
NormalizedName = name.ToUpperInvariant();
|
||||
ConcurrencyStamp = Guid.NewGuid().ToString();
|
||||
|
||||
Claims = new Collection<IdentityRoleClaim>();
|
||||
}
|
||||
|
||||
public virtual void AddClaim([NotNull] IGuidGenerator guidGenerator, [NotNull] Claim claim)
|
||||
{
|
||||
Check.NotNull(guidGenerator, nameof(guidGenerator));
|
||||
Check.NotNull(claim, nameof(claim));
|
||||
|
||||
Claims.Add(new IdentityRoleClaim(guidGenerator.Create(), Id, claim, TenantId));
|
||||
}
|
||||
|
||||
public virtual void AddClaims([NotNull] IGuidGenerator guidGenerator, [NotNull] IEnumerable<Claim> claims)
|
||||
{
|
||||
Check.NotNull(guidGenerator, nameof(guidGenerator));
|
||||
Check.NotNull(claims, nameof(claims));
|
||||
|
||||
foreach (var claim in claims)
|
||||
{
|
||||
AddClaim(guidGenerator, claim);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RemoveClaim([NotNull] Claim claim)
|
||||
{
|
||||
Check.NotNull(claim, nameof(claim));
|
||||
|
||||
Claims.RemoveAll(c => c.ClaimType == claim.Type && c.ClaimValue == claim.Value);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{base.ToString()}, Name = {Name}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Security.Claims;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Volo.Abp.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a claim that is granted to all users within a role.
|
||||
/// </summary>
|
||||
public class IdentityRoleClaim : IdentityClaim
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the of the primary key of the role associated with this claim.
|
||||
/// </summary>
|
||||
public virtual Guid RoleId { get; protected set; }
|
||||
|
||||
protected IdentityRoleClaim()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected internal IdentityRoleClaim(
|
||||
Guid id,
|
||||
Guid roleId,
|
||||
[NotNull] Claim claim,
|
||||
Guid? tenantId)
|
||||
: base(
|
||||
id,
|
||||
claim,
|
||||
tenantId)
|
||||
{
|
||||
RoleId = roleId;
|
||||
}
|
||||
|
||||
protected internal IdentityRoleClaim(
|
||||
Guid id,
|
||||
Guid roleId,
|
||||
[NotNull] string claimType,
|
||||
string claimValue,
|
||||
Guid? tenantId)
|
||||
: base(
|
||||
id,
|
||||
claimType,
|
||||
claimValue,
|
||||
tenantId)
|
||||
{
|
||||
RoleId = roleId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
using Volo.Abp.Threading;
|
||||
|
||||
namespace Volo.Abp.Identity
|
||||
{
|
||||
public static class IdentityRoleRepositoryExtensions
|
||||
{
|
||||
public static IdentityRole FindByNormalizedName(this IIdentityRoleRepository roleRepository, string normalizedRoleName)
|
||||
{
|
||||
return AsyncHelper.RunSync(() => roleRepository.FindByNormalizedNameAsync(normalizedRoleName));
|
||||
}
|
||||
|
||||
//TODO: Other sync extension methods
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,293 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.Guids;
|
||||
|
||||
namespace Volo.Abp.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of a persistence store for roles.
|
||||
/// </summary>
|
||||
public class IdentityRoleStore :
|
||||
IRoleStore<IdentityRole>,
|
||||
IRoleClaimStore<IdentityRole>,
|
||||
ITransientDependency
|
||||
{
|
||||
private readonly IIdentityRoleRepository _roleRepository;
|
||||
private readonly ILogger<IdentityRoleStore> _logger;
|
||||
private readonly IGuidGenerator _guidGenerator;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new instance of <see cref="IdentityRoleStore"/>.
|
||||
/// </summary>
|
||||
public IdentityRoleStore(
|
||||
IIdentityRoleRepository roleRepository,
|
||||
ILogger<IdentityRoleStore> logger,
|
||||
IGuidGenerator guidGenerator,
|
||||
IdentityErrorDescriber describer = null)
|
||||
{
|
||||
_roleRepository = roleRepository;
|
||||
_logger = logger;
|
||||
_guidGenerator = guidGenerator;
|
||||
|
||||
ErrorDescriber = describer ?? new IdentityErrorDescriber();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="IdentityErrorDescriber"/> for any error that occurred with the current operation.
|
||||
/// </summary>
|
||||
public IdentityErrorDescriber ErrorDescriber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a flag indicating if changes should be persisted after CreateAsync, UpdateAsync and DeleteAsync are called.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// True if changes should be automatically persisted, otherwise false.
|
||||
/// </value>
|
||||
public bool AutoSaveChanges { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new role in a store as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role to create in the store.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="IdentityResult"/> of the asynchronous query.</returns>
|
||||
public virtual async Task<IdentityResult> CreateAsync([NotNull] IdentityRole role, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
Check.NotNull(role, nameof(role));
|
||||
|
||||
await _roleRepository.InsertAsync(role, AutoSaveChanges, cancellationToken);
|
||||
|
||||
return IdentityResult.Success;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a role in a store as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role to update in the store.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="IdentityResult"/> of the asynchronous query.</returns>
|
||||
public virtual async Task<IdentityResult> UpdateAsync([NotNull] IdentityRole role, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
Check.NotNull(role, nameof(role));
|
||||
|
||||
try
|
||||
{
|
||||
await _roleRepository.UpdateAsync(role, AutoSaveChanges, cancellationToken);
|
||||
}
|
||||
catch (AbpDbConcurrencyException ex)
|
||||
{
|
||||
_logger.LogWarning(ex.ToString()); //Trigger some AbpHandledException event
|
||||
return IdentityResult.Failed(ErrorDescriber.ConcurrencyFailure());
|
||||
}
|
||||
|
||||
return IdentityResult.Success;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a role from the store as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role to delete from the store.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that represents the <see cref="IdentityResult"/> of the asynchronous query.</returns>
|
||||
public virtual async Task<IdentityResult> DeleteAsync([NotNull] IdentityRole role, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
Check.NotNull(role, nameof(role));
|
||||
|
||||
try
|
||||
{
|
||||
await _roleRepository.DeleteAsync(role, AutoSaveChanges, cancellationToken);
|
||||
}
|
||||
catch (AbpDbConcurrencyException ex)
|
||||
{
|
||||
_logger.LogWarning(ex.ToString()); //Trigger some AbpHandledException event
|
||||
return IdentityResult.Failed(ErrorDescriber.ConcurrencyFailure());
|
||||
}
|
||||
|
||||
return IdentityResult.Success;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ID for a role from the store as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role whose ID should be returned.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that contains the ID of the role.</returns>
|
||||
public Task<string> GetRoleIdAsync([NotNull] IdentityRole role, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
Check.NotNull(role, nameof(role));
|
||||
|
||||
return Task.FromResult(role.Id.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of a role from the store as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role whose name should be returned.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that contains the name of the role.</returns>
|
||||
public Task<string> GetRoleNameAsync([NotNull] IdentityRole role, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
Check.NotNull(role, nameof(role));
|
||||
|
||||
return Task.FromResult(role.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the name of a role in the store as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role whose name should be set.</param>
|
||||
/// <param name="roleName">The name of the role.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
|
||||
public Task SetRoleNameAsync([NotNull] IdentityRole role, string roleName, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
Check.NotNull(role, nameof(role));
|
||||
|
||||
role.Name = roleName;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the role who has the specified ID as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="id">The role ID to look for.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that result of the look up.</returns>
|
||||
public virtual Task<IdentityRole> FindByIdAsync(string id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
return _roleRepository.FindAsync(Guid.Parse(id), cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the role who has the specified normalized name as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="normalizedName">The normalized role name to look for.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that result of the look up.</returns>
|
||||
public virtual Task<IdentityRole> FindByNameAsync([NotNull] string normalizedName, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
Check.NotNull(normalizedName, nameof(normalizedName));
|
||||
|
||||
return _roleRepository.FindByNormalizedNameAsync(normalizedName, cancellationToken: cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a role's normalized name as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role whose normalized name should be retrieved.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that contains the name of the role.</returns>
|
||||
public virtual Task<string> GetNormalizedRoleNameAsync([NotNull] IdentityRole role, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
Check.NotNull(role, nameof(role));
|
||||
|
||||
return Task.FromResult(role.NormalizedName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set a role's normalized name as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role whose normalized name should be set.</param>
|
||||
/// <param name="normalizedName">The normalized name to set</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
|
||||
public virtual Task SetNormalizedRoleNameAsync([NotNull] IdentityRole role, string normalizedName, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
Check.NotNull(role, nameof(role));
|
||||
|
||||
role.NormalizedName = normalizedName;
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dispose the stores
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the claims associated with the specified <paramref name="role"/> as an asynchronous operation.
|
||||
/// </summary>
|
||||
/// <param name="role">The role whose claims should be retrieved.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that contains the claims granted to a role.</returns>
|
||||
public async Task<IList<Claim>> GetClaimsAsync([NotNull] IdentityRole role, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
Check.NotNull(role, nameof(role));
|
||||
|
||||
await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken);
|
||||
|
||||
return role.Claims.Select(c => c.ToClaim()).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds the <paramref name="claim"/> given to the specified <paramref name="role"/>.
|
||||
/// </summary>
|
||||
/// <param name="role">The role to add the claim to.</param>
|
||||
/// <param name="claim">The claim to add to the role.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
|
||||
public async Task AddClaimAsync([NotNull] IdentityRole role, [NotNull] Claim claim, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
Check.NotNull(role, nameof(role));
|
||||
Check.NotNull(claim, nameof(claim));
|
||||
|
||||
await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken);
|
||||
|
||||
role.AddClaim(_guidGenerator, claim);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the <paramref name="claim"/> given from the specified <paramref name="role"/>.
|
||||
/// </summary>
|
||||
/// <param name="role">The role to remove the claim from.</param>
|
||||
/// <param name="claim">The claim to remove from the role.</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
|
||||
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
|
||||
public async Task RemoveClaimAsync([NotNull] IdentityRole role, [NotNull] Claim claim, CancellationToken cancellationToken = default)
|
||||
{
|
||||
Check.NotNull(role, nameof(role));
|
||||
Check.NotNull(claim, nameof(claim));
|
||||
|
||||
await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken);
|
||||
|
||||
role.RemoveClaim(claim);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,269 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.Guids;
|
||||
using Volo.Abp.Users;
|
||||
|
||||
namespace Volo.Abp.Identity
|
||||
{
|
||||
public class IdentityUser : AggregateRoot<Guid>, IHasConcurrencyStamp, IUser, IHasExtraProperties
|
||||
{
|
||||
public virtual Guid? TenantId { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user name for this user.
|
||||
/// </summary>
|
||||
public virtual string UserName { get; protected internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the normalized user name for this user.
|
||||
/// </summary>
|
||||
public virtual string NormalizedUserName { get; protected internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the email address for this user.
|
||||
/// </summary>
|
||||
public virtual string Email { get; protected internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the normalized email address for this user.
|
||||
/// </summary>
|
||||
public virtual string NormalizedEmail { get; protected internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a flag indicating if a user has confirmed their email address.
|
||||
/// </summary>
|
||||
/// <value>True if the email address has been confirmed, otherwise false.</value>
|
||||
public virtual bool EmailConfirmed { get; protected internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a salted and hashed representation of the password for this user.
|
||||
/// </summary>
|
||||
public virtual string PasswordHash { get; protected internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// A random value that must change whenever a users credentials change (password changed, login removed)
|
||||
/// </summary>
|
||||
public virtual string SecurityStamp { get; protected internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// A random value that must change whenever a user is persisted to the store
|
||||
/// </summary>
|
||||
public virtual string ConcurrencyStamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a telephone number for the user.
|
||||
/// </summary>
|
||||
public virtual string PhoneNumber { get; protected internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a flag indicating if a user has confirmed their telephone address.
|
||||
/// </summary>
|
||||
/// <value>True if the telephone number has been confirmed, otherwise false.</value>
|
||||
public virtual bool PhoneNumberConfirmed { get; protected internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a flag indicating if two factor authentication is enabled for this user.
|
||||
/// </summary>
|
||||
/// <value>True if 2fa is enabled, otherwise false.</value>
|
||||
public virtual bool TwoFactorEnabled { get; protected internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date and time, in UTC, when any user lockout ends.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A value in the past means the user is not locked out.
|
||||
/// </remarks>
|
||||
public virtual DateTimeOffset? LockoutEnd { get; protected internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a flag indicating if the user could be locked out.
|
||||
/// </summary>
|
||||
/// <value>True if the user could be locked out, otherwise false.</value>
|
||||
public virtual bool LockoutEnabled { get; protected internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the number of failed login attempts for the current user.
|
||||
/// </summary>
|
||||
public virtual int AccessFailedCount { get; protected internal set; }
|
||||
|
||||
//TODO: Can we make collections readonly collection, which will provide encapsulation. But... can work for all ORMs?
|
||||
|
||||
/// <summary>
|
||||
/// Navigation property for the roles this user belongs to.
|
||||
/// </summary>
|
||||
public virtual ICollection<IdentityUserRole> Roles { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Navigation property for the claims this user possesses.
|
||||
/// </summary>
|
||||
public virtual ICollection<IdentityUserClaim> Claims { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Navigation property for this users login accounts.
|
||||
/// </summary>
|
||||
public virtual ICollection<IdentityUserLogin> Logins { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Navigation property for this users tokens.
|
||||
/// </summary>
|
||||
public virtual ICollection<IdentityUserToken> Tokens { get; protected set; }
|
||||
|
||||
public Dictionary<string, object> ExtraProperties { get; protected set; }
|
||||
|
||||
protected IdentityUser()
|
||||
{
|
||||
ExtraProperties = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
public IdentityUser(Guid id, [NotNull] string userName, [NotNull] string email, Guid? tenantId = null)
|
||||
{
|
||||
Check.NotNull(userName, nameof(userName));
|
||||
|
||||
Id = id;
|
||||
TenantId = tenantId;
|
||||
UserName = userName;
|
||||
NormalizedUserName = userName.ToUpperInvariant();
|
||||
Email = email;
|
||||
NormalizedEmail = email.ToUpperInvariant();
|
||||
ConcurrencyStamp = Guid.NewGuid().ToString();
|
||||
SecurityStamp = Guid.NewGuid().ToString();
|
||||
|
||||
Roles = new Collection<IdentityUserRole>();
|
||||
Claims = new Collection<IdentityUserClaim>();
|
||||
Logins = new Collection<IdentityUserLogin>();
|
||||
Tokens = new Collection<IdentityUserToken>();
|
||||
|
||||
ExtraProperties = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
public virtual void AddRole(Guid roleId)
|
||||
{
|
||||
Check.NotNull(roleId, nameof(roleId));
|
||||
|
||||
if (IsInRole(roleId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Roles.Add(new IdentityUserRole(Id, roleId, TenantId));
|
||||
}
|
||||
|
||||
public virtual void RemoveRole(Guid roleId)
|
||||
{
|
||||
Check.NotNull(roleId, nameof(roleId));
|
||||
|
||||
if (!IsInRole(roleId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Roles.RemoveAll(r => r.RoleId == roleId);
|
||||
}
|
||||
|
||||
public virtual bool IsInRole(Guid roleId)
|
||||
{
|
||||
Check.NotNull(roleId, nameof(roleId));
|
||||
|
||||
return Roles.Any(r => r.RoleId == roleId);
|
||||
}
|
||||
|
||||
public virtual void AddClaim([NotNull] IGuidGenerator guidGenerator, [NotNull] Claim claim)
|
||||
{
|
||||
Check.NotNull(guidGenerator, nameof(guidGenerator));
|
||||
Check.NotNull(claim, nameof(claim));
|
||||
|
||||
Claims.Add(new IdentityUserClaim(guidGenerator.Create(), Id, claim, TenantId));
|
||||
}
|
||||
|
||||
public virtual void AddClaims([NotNull] IGuidGenerator guidGenerator, [NotNull] IEnumerable<Claim> claims)
|
||||
{
|
||||
Check.NotNull(guidGenerator, nameof(guidGenerator));
|
||||
Check.NotNull(claims, nameof(claims));
|
||||
|
||||
foreach (var claim in claims)
|
||||
{
|
||||
AddClaim(guidGenerator, claim);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ReplaceClaim([NotNull] Claim claim, [NotNull] Claim newClaim)
|
||||
{
|
||||
Check.NotNull(claim, nameof(claim));
|
||||
Check.NotNull(newClaim, nameof(newClaim));
|
||||
|
||||
var userClaims = Claims.Where(uc => uc.ClaimValue == claim.Value && uc.ClaimType == claim.Type);
|
||||
foreach (var userClaim in userClaims)
|
||||
{
|
||||
userClaim.SetClaim(newClaim);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RemoveClaims([NotNull] IEnumerable<Claim> claims)
|
||||
{
|
||||
Check.NotNull(claims, nameof(claims));
|
||||
|
||||
foreach (var claim in claims)
|
||||
{
|
||||
RemoveClaim(claim);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RemoveClaim([NotNull] Claim claim)
|
||||
{
|
||||
Check.NotNull(claim, nameof(claim));
|
||||
|
||||
Claims.RemoveAll(c => c.ClaimValue == claim.Value && c.ClaimType == claim.Type);
|
||||
}
|
||||
|
||||
public virtual void AddLogin([NotNull] UserLoginInfo login)
|
||||
{
|
||||
Check.NotNull(login, nameof(login));
|
||||
|
||||
Logins.Add(new IdentityUserLogin(Id, login, TenantId));
|
||||
}
|
||||
|
||||
public virtual void RemoveLogin([NotNull] string loginProvider, [NotNull] string providerKey)
|
||||
{
|
||||
Check.NotNull(loginProvider, nameof(loginProvider));
|
||||
Check.NotNull(providerKey, nameof(providerKey));
|
||||
|
||||
Logins.RemoveAll(userLogin => userLogin.LoginProvider == loginProvider && userLogin.ProviderKey == providerKey);
|
||||
}
|
||||
|
||||
[CanBeNull]
|
||||
public virtual IdentityUserToken FindToken(string loginProvider, string name)
|
||||
{
|
||||
return Tokens.FirstOrDefault(t => t.LoginProvider == loginProvider && t.Name == name);
|
||||
}
|
||||
|
||||
public virtual void SetToken(string loginProvider, string name, string value)
|
||||
{
|
||||
var token = FindToken(loginProvider, name);
|
||||
if (token == null)
|
||||
{
|
||||
Tokens.Add(new IdentityUserToken(Id, loginProvider, name, value, TenantId));
|
||||
}
|
||||
else
|
||||
{
|
||||
token.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RemoveToken(string loginProvider, string name)
|
||||
{
|
||||
Tokens.RemoveAll(t => t.LoginProvider == loginProvider && t.Name == name);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{base.ToString()}, UserName = {UserName}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Security.Claims;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Volo.Abp.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a claim that a user possesses.
|
||||
/// </summary>
|
||||
public class IdentityUserClaim : IdentityClaim
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the primary key of the user associated with this claim.
|
||||
/// </summary>
|
||||
public virtual Guid UserId { get; protected set; }
|
||||
|
||||
protected IdentityUserClaim()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected internal IdentityUserClaim(Guid id, Guid userId, [NotNull] Claim claim, Guid? tenantId)
|
||||
: base(id, claim, tenantId)
|
||||
{
|
||||
UserId = userId;
|
||||
}
|
||||
|
||||
protected internal IdentityUserClaim(Guid id, Guid userId, [NotNull] string claimType, string claimValue, Guid? tenantId)
|
||||
: base(id, claimType, claimValue, tenantId)
|
||||
{
|
||||
UserId = userId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
|
||||
namespace Volo.Abp.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a login and its associated provider for a user.
|
||||
/// </summary>
|
||||
public class IdentityUserLogin : Entity, IMultiTenant
|
||||
{
|
||||
public virtual Guid? TenantId { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the of the primary key of the user associated with this login.
|
||||
/// </summary>
|
||||
public virtual Guid UserId { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the login provider for the login (e.g. facebook, google)
|
||||
/// </summary>
|
||||
public virtual string LoginProvider { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the unique provider identifier for this login.
|
||||
/// </summary>
|
||||
public virtual string ProviderKey { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the friendly name used in a UI for this login.
|
||||
/// </summary>
|
||||
public virtual string ProviderDisplayName { get; protected set; }
|
||||
|
||||
protected IdentityUserLogin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected internal IdentityUserLogin(
|
||||
Guid userId,
|
||||
[NotNull] string loginProvider,
|
||||
[NotNull] string providerKey,
|
||||
string providerDisplayName,
|
||||
Guid? tenantId)
|
||||
{
|
||||
Check.NotNull(loginProvider, nameof(loginProvider));
|
||||
Check.NotNull(providerKey, nameof(providerKey));
|
||||
|
||||
UserId = userId;
|
||||
LoginProvider = loginProvider;
|
||||
ProviderKey = providerKey;
|
||||
ProviderDisplayName = providerDisplayName;
|
||||
TenantId = tenantId;
|
||||
}
|
||||
|
||||
protected internal IdentityUserLogin(
|
||||
Guid userId,
|
||||
[NotNull] UserLoginInfo login,
|
||||
Guid? tenantId)
|
||||
: this(
|
||||
userId,
|
||||
login.LoginProvider,
|
||||
login.ProviderKey,
|
||||
login.ProviderDisplayName,
|
||||
tenantId)
|
||||
{
|
||||
}
|
||||
|
||||
public UserLoginInfo ToUserLoginInfo()
|
||||
{
|
||||
return new UserLoginInfo(LoginProvider, ProviderKey, ProviderDisplayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
|
||||
namespace Volo.Abp.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the link between a user and a role.
|
||||
/// </summary>
|
||||
public class IdentityUserRole : Entity, IMultiTenant
|
||||
{
|
||||
public virtual Guid? TenantId { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the primary key of the user that is linked to a role.
|
||||
/// </summary>
|
||||
public virtual Guid UserId { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the primary key of the role that is linked to the user.
|
||||
/// </summary>
|
||||
public virtual Guid RoleId { get; protected set; }
|
||||
|
||||
protected IdentityUserRole()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected internal IdentityUserRole(Guid userId, Guid roleId, Guid? tenantId)
|
||||
{
|
||||
UserId = userId;
|
||||
RoleId = roleId;
|
||||
TenantId = tenantId;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
|
||||
namespace Volo.Abp.Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an authentication token for a user.
|
||||
/// </summary>
|
||||
public class IdentityUserToken : Entity, IMultiTenant
|
||||
{
|
||||
public virtual Guid? TenantId { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the primary key of the user that the token belongs to.
|
||||
/// </summary>
|
||||
public virtual Guid UserId { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the LoginProvider this token is from.
|
||||
/// </summary>
|
||||
public virtual string LoginProvider { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the token.
|
||||
/// </summary>
|
||||
public virtual string Name { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the token value.
|
||||
/// </summary>
|
||||
public virtual string Value { get; set; }
|
||||
|
||||
protected IdentityUserToken()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected internal IdentityUserToken(
|
||||
Guid userId,
|
||||
[NotNull] string loginProvider,
|
||||
[NotNull] string name,
|
||||
string value,
|
||||
Guid? tenantId)
|
||||
{
|
||||
Check.NotNull(loginProvider, nameof(loginProvider));
|
||||
Check.NotNull(name, nameof(name));
|
||||
|
||||
UserId = userId;
|
||||
LoginProvider = loginProvider;
|
||||
Name = name;
|
||||
Value = value;
|
||||
TenantId = tenantId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp71</s:String></wpf:ResourceDictionary>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue