mirror of https://github.com/abpframework/abp.git
18 changed files with 12 additions and 246 deletions
@ -1,21 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<AssemblyName>Volo.Abp.Users</AssemblyName> |
|||
<PackageId>Volo.Abp.Users</PackageId> |
|||
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Abp.Security\Volo.Abp.Security.csproj" /> |
|||
<ProjectReference Include="..\Volo.Abp.Settings\Volo.Abp.Settings.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -1,2 +0,0 @@ |
|||
<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> |
|||
@ -1,43 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace Volo.Abp.Settings |
|||
{ |
|||
//TODO: Consider to move to another package?
|
|||
|
|||
public static class UserSettingManagerExtensions |
|||
{ |
|||
public static Task<string> GetOrNullForUserAsync(this ISettingManager settingManager, [NotNull] string name, Guid userId, bool fallback = true) |
|||
{ |
|||
return settingManager.GetOrNullAsync(name, UserSettingValueProvider.ProviderName, userId.ToString(), fallback); |
|||
} |
|||
|
|||
public static Task<string> GetOrNullForCurrentUserAsync(this ISettingManager settingManager, [NotNull] string name, bool fallback = true) |
|||
{ |
|||
return settingManager.GetOrNullAsync(name, UserSettingValueProvider.ProviderName, null, fallback); |
|||
} |
|||
|
|||
public static Task<List<SettingValue>> GetAllForUserAsync(this ISettingManager settingManager, Guid userId, bool fallback = true) |
|||
{ |
|||
return settingManager.GetAllAsync(UserSettingValueProvider.ProviderName, userId.ToString(), fallback); |
|||
} |
|||
|
|||
public static Task<List<SettingValue>> GetAllForCurrentUserAsync(this ISettingManager settingManager, bool fallback = true) |
|||
{ |
|||
return settingManager.GetAllAsync(UserSettingValueProvider.ProviderName, null, fallback); |
|||
} |
|||
|
|||
public static Task SetForUserAsync(this ISettingManager settingManager, Guid userId, [NotNull] string name, [CanBeNull] string value, bool forceToSet = false) |
|||
{ |
|||
return settingManager.SetAsync(name, value, UserSettingValueProvider.ProviderName, userId.ToString(), forceToSet); |
|||
} |
|||
|
|||
public static Task SetForCurrentUserAsync(this ISettingManager settingManager, [NotNull] string name, [CanBeNull] string value, bool forceToSet = false) |
|||
{ |
|||
return settingManager.SetAsync(name, value, UserSettingValueProvider.ProviderName, null, forceToSet); |
|||
} |
|||
} |
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.Security; |
|||
using Volo.Abp.Settings; |
|||
|
|||
namespace Volo.Abp.Users |
|||
{ |
|||
[DependsOn(typeof(AbpSecurityModule))] |
|||
[DependsOn(typeof(AbpSettingsModule))] |
|||
public class AbpUsersModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.Configure<SettingOptions>(options => |
|||
{ |
|||
options.ValueProviders.Add<UserSettingValueProvider>(); |
|||
}); |
|||
|
|||
services.AddAssemblyOf<AbpUsersModule>(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
using System; |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace Volo.Abp.Users |
|||
{ |
|||
public interface IUserInfo |
|||
{ |
|||
Guid Id { get; } |
|||
|
|||
string UserName { get; } |
|||
|
|||
[CanBeNull] |
|||
string Email { get; } |
|||
|
|||
bool EmailConfirmed { get; } |
|||
|
|||
[CanBeNull] |
|||
string PhoneNumber { get; } |
|||
|
|||
bool PhoneNumberConfirmed { get; } |
|||
} |
|||
} |
|||
@ -1,14 +0,0 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Volo.Abp.Users |
|||
{ |
|||
public interface IUserLookupService |
|||
{ |
|||
Task<IUserInfo> FindByIdAsync(Guid id); |
|||
|
|||
Task<IUserInfo> FindByUserNameAsync(string userName); |
|||
|
|||
//TODO: Searching users...
|
|||
} |
|||
} |
|||
@ -1,21 +0,0 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Abp.Users |
|||
{ |
|||
public class NullUserLookupService : IUserLookupService, ISingletonDependency |
|||
{ |
|||
private static readonly Task<IUserInfo> NullUserResult = Task.FromResult((IUserInfo) null); |
|||
|
|||
public Task<IUserInfo> FindByIdAsync(Guid id) |
|||
{ |
|||
return NullUserResult; |
|||
} |
|||
|
|||
public Task<IUserInfo> FindByUserNameAsync(string userName) |
|||
{ |
|||
return NullUserResult; |
|||
} |
|||
} |
|||
} |
|||
@ -1,38 +0,0 @@ |
|||
using System; |
|||
using JetBrains.Annotations; |
|||
|
|||
namespace Volo.Abp.Users |
|||
{ |
|||
public class UserInfo : IUserInfo |
|||
{ |
|||
public Guid Id { get; } |
|||
|
|||
public string UserName { get; } |
|||
|
|||
public string Email { get; } |
|||
|
|||
public bool EmailConfirmed { get; } |
|||
|
|||
public string PhoneNumber { get; } |
|||
|
|||
public bool PhoneNumberConfirmed { get; } |
|||
|
|||
public UserInfo( |
|||
Guid id, |
|||
[NotNull] string userName, |
|||
[CanBeNull] string email = null, |
|||
bool emailConfirmed = false, |
|||
[CanBeNull] string phoneNumber = null, |
|||
bool phoneNumberConfirmed = false) |
|||
{ |
|||
Check.NotNull(userName, nameof(userName)); |
|||
|
|||
Id = id; |
|||
UserName = userName; |
|||
Email = email; |
|||
EmailConfirmed = emailConfirmed; |
|||
PhoneNumber = phoneNumber; |
|||
PhoneNumberConfirmed = phoneNumberConfirmed; |
|||
} |
|||
} |
|||
} |
|||
@ -1,47 +0,0 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Settings; |
|||
|
|||
namespace Volo.Abp.Users |
|||
{ |
|||
//TODO: Optimization: Get all settings and cache it!
|
|||
|
|||
public class UserSettingValueProvider : SettingValueProvider |
|||
{ |
|||
public const string ProviderName = "User"; |
|||
|
|||
public override string Name => ProviderName; |
|||
|
|||
protected ICurrentUser CurrentUser { get; } |
|||
|
|||
public UserSettingValueProvider(ISettingStore settingStore, ICurrentUser currentUser) |
|||
: base(settingStore) |
|||
{ |
|||
CurrentUser = currentUser; |
|||
} |
|||
|
|||
public override async Task<string> GetOrNullAsync(SettingDefinition setting, string providerKey) |
|||
{ |
|||
if (providerKey == null) |
|||
{ |
|||
if (CurrentUser.Id == null) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
providerKey = CurrentUser.Id.ToString(); |
|||
} |
|||
|
|||
return await SettingStore.GetOrNullAsync(setting.Name, Name, providerKey); |
|||
} |
|||
|
|||
public override Task SetAsync(SettingDefinition setting, string value, string providerKey) |
|||
{ |
|||
return SettingStore.SetAsync(setting.Name, value, Name, providerKey); |
|||
} |
|||
|
|||
public override Task ClearAsync(SettingDefinition setting, string providerKey) |
|||
{ |
|||
return SettingStore.DeleteAsync(setting.Name, Name, providerKey); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue