XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEExtension.NetCore.ServerInteractive

[DLL] Server interaction extension, including user identity verification and querying in conjunction with AutoConfig

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFEExtension.NetCore.ServerInteractive

现在,可以返回自己的用户登录模型,而非固定的继承于IUserFaceInfo的模型

225bc9d
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

5 个文件 +28 -17
Added XFEExtension.NetCore.ServerInteractive/Utilities/Server/Services/CoreService/ServerCoreUserLoginServiceBase.cs +13 -0
@@ -0,0 +1,13 @@
1 namespace XFEExtension.NetCore.ServerInteractive.Utilities.Server.Services.CoreService;
2
3 /// <summary>
4 /// 服务器核心用户登录服务基类
5 /// </summary>
6 /// <typeparam name="T">登录返回类型</typeparam>
7 public abstract class ServerCoreUserLoginServiceBase<T> : ServerCoreUserServiceBase where T : class
8 {
9 /// <summary>
10 /// 用户登录结果转换函数
11 /// </summary>
12 public Func<object, T> LoginResultConvertFunction { get; set; } = user => (T)user;
13 }
Modified XFEExtension.NetCore.ServerInteractive/Utilities/Server/Services/CoreService/UserLoginService.cs +3 -4
@@ -1,5 +1,4 @@
1 1 using System.Net;
2 using XFEExtension.NetCore.ServerInteractive.Interfaces;
3 2 using XFEExtension.NetCore.ServerInteractive.Models.ServerModels;
4 3 using XFEExtension.NetCore.ServerInteractive.Models.UserModels;
5 4 using XFEExtension.NetCore.ServerInteractive.Utilities.Helpers;
@@ -12,7 +11,7 @@ namespace XFEExtension.NetCore.ServerInteractive.Utilities.Server.Services.CoreS
12 11 /// <summary>
13 12 /// 用户登录服务
14 13 /// </summary>
15 public class UserLoginService<T> : ServerCoreUserServiceBase where T : IUserFaceInfo
14 public class UserLoginService<T> : ServerCoreUserLoginServiceBase<T> where T : class
16 15 {
17 16 /// <inheritdoc/>
18 17 public override async Task StandardRequestReceived(string execute, QueryableJsonNode queryableJsonNode, ServerCoreReturnArgs r)
@@ -57,7 +56,7 @@ public class UserLoginService<T> : ServerCoreUserServiceBase where T : IUserFace
57 56 {
58 57 session = $"{user.ID}|{UserHelper.Encrypt(userLogin.Key, userLogin.UserLoginModel)}",
59 58 expireDate = userLogin.UserLoginModel.EndDateTime,
60 userInfo = (T)user
59 userInfo = LoginResultConvertFunction(user)
61 60 }.ToJson(), HttpStatusCode.OK);
62 61 }
63 62 else
@@ -70,7 +69,7 @@ public class UserLoginService<T> : ServerCoreUserServiceBase where T : IUserFace
70 69 {
71 70 session = $"{user.ID}|{UserHelper.Encrypt(userLogin.Key, userLogin.UserLoginModel)}",
72 71 expireDate = userLogin.UserLoginModel.EndDateTime,
73 userInfo = (T)user
72 userInfo = LoginResultConvertFunction(user)
74 73 }.ToJson(), HttpStatusCode.OK);
75 74 }
76 75 }
Modified XFEExtension.NetCore.ServerInteractive/Utilities/Server/Services/CoreService/UserReloginService.cs +2 -3
@@ -1,6 +1,5 @@
1 1 using System.Net;
2 2 using System.Text.RegularExpressions;
3 using XFEExtension.NetCore.ServerInteractive.Interfaces;
4 3 using XFEExtension.NetCore.ServerInteractive.Models.ServerModels;
5 4 using XFEExtension.NetCore.ServerInteractive.Models.UserModels;
6 5 using XFEExtension.NetCore.ServerInteractive.Utilities.Helpers;
@@ -13,7 +12,7 @@ namespace XFEExtension.NetCore.ServerInteractive.Utilities.Server.Services.CoreS
13 12 /// <summary>
14 13 /// 用户登录校验服务
15 14 /// </summary>
16 public class UserReloginService<T> : ServerCoreUserServiceBase where T : IUserFaceInfo
15 public class UserReloginService<T> : ServerCoreUserLoginServiceBase<T> where T : class
17 16 {
18 17 /// <inheritdoc/>
19 18 public override async Task StandardRequestReceived(string execute, QueryableJsonNode queryableJsonNode, ServerCoreReturnArgs r)
@@ -34,6 +33,6 @@ public class UserReloginService<T> : ServerCoreUserServiceBase where T : IUserFa
34 33 if (userLoginModel.LastIPAddress != r.Args.ClientIP) r.Error("IP地址不匹配", HttpStatusCode.Forbidden);
35 34 if (userLoginModel.LastIPAddress != encryptedUserLoginModel.UserLoginModel.LastIPAddress) r.Error("IP地址不匹配", HttpStatusCode.Forbidden);
36 35 if (userLoginModel.EndDateTime < DateTime.Now) r.Error("登录已过期", HttpStatusCode.Forbidden);
37 await r.Args.ReplyAndClose(((T)user).ToJson());
36 await r.Args.ReplyAndClose(LoginResultConvertFunction(user).ToJson());
38 37 }
39 38 }
Modified XFEExtension.NetCore.ServerInteractive/Utilities/XFEServerCoreBuilderExtensions.cs +2 -2
@@ -43,7 +43,7 @@ public static class XFEServerCoreBuilderExtensions
43 43 /// <typeparam name="T">登录返回用户接口类型</typeparam>
44 44 /// <param name="xFEServerCoreBuilder"></param>
45 45 /// <returns></returns>
46 public static XFEServerCoreBuilder AddStandardLoginService<T>(this XFEServerCoreBuilder xFEServerCoreBuilder) where T : IUserFaceInfo => xFEServerCoreBuilder.RegisterStandardAsyncService<UserLoginService<T>>("login")
46 public static XFEServerCoreBuilder AddStandardLoginService<T>(this XFEServerCoreBuilder xFEServerCoreBuilder) where T : class => xFEServerCoreBuilder.RegisterStandardAsyncService<UserLoginService<T>>("login")
47 47 .RegisterStandardAsyncService<UserReloginService<T>>("relogin")
48 48 .AddService<UserLoginAutoCleanService>();
49 49
@@ -94,7 +94,7 @@ public static class XFEServerCoreBuilderExtensions
94 94 /// <param name="getLoginKeepDays"></param>
95 95 /// <param name="xFEDataTableManagerBuilder"></param>
96 96 /// <returns></returns>
97 public static XFEServerCoreBuilder UseXFEStandardServerCore<T>(this XFEServerCoreBuilder xFEServerCoreBuilder, Func<IEnumerable<User>> getUserFunction, Func<IEnumerable<EncryptedUserLoginModel>> getEncryptedUserLoginModelFunction, Action<EncryptedUserLoginModel> addEncryptedUserLoginModelFunction, Action<EncryptedUserLoginModel> removeEncryptedUserLoginModelFunction, Func<int> getLoginKeepDays, XFEDataTableManagerBuilder xFEDataTableManagerBuilder) where T : IUserFaceInfo => xFEServerCoreBuilder.AddUserParameterBase(getUserFunction, getEncryptedUserLoginModelFunction, addEncryptedUserLoginModelFunction, removeEncryptedUserLoginModelFunction, getLoginKeepDays)
97 public static XFEServerCoreBuilder UseXFEStandardServerCore<T>(this XFEServerCoreBuilder xFEServerCoreBuilder, Func<IEnumerable<User>> getUserFunction, Func<IEnumerable<EncryptedUserLoginModel>> getEncryptedUserLoginModelFunction, Action<EncryptedUserLoginModel> addEncryptedUserLoginModelFunction, Action<EncryptedUserLoginModel> removeEncryptedUserLoginModelFunction, Func<int> getLoginKeepDays, XFEDataTableManagerBuilder xFEDataTableManagerBuilder) where T : class => xFEServerCoreBuilder.AddUserParameterBase(getUserFunction, getEncryptedUserLoginModelFunction, addEncryptedUserLoginModelFunction, removeEncryptedUserLoginModelFunction, getLoginKeepDays)
98 98 .AddDataTableManager(xFEDataTableManagerBuilder, getUserFunction, getEncryptedUserLoginModelFunction)
99 99 .AddEntryPotinVerify()
100 100 .AddDailyCounterService()
Modified XFEExtension.NetCore.ServerInteractive/XFEExtension.NetCore.ServerInteractive.csproj +8 -8
@@ -5,7 +5,7 @@
5 5 <ImplicitUsings>enable</ImplicitUsings>
6 6 <Nullable>enable</Nullable>
7 7 <GenerateDocumentationFile>True</GenerateDocumentationFile>
8 <Version>1.0.6</Version>
8 <Version>1.0.7</Version>
9 9 <Title>XFEExtension.NetCore.ServerInteractive</Title>
10 10 <RepositoryUrl>https://github.com/XFEstudio/XFEExtension.NetCore.ServerInteractive</RepositoryUrl>
11 11 <AnalysisLevel>latest</AnalysisLevel>
@@ -19,18 +19,18 @@
19 19 <PackageReadmeFile>README.md</PackageReadmeFile>
20 20 <PackageTags>XFE;Server;服务器;XFEExtension</PackageTags>
21 21 <PackageReleaseNotes>
22 ## 调整
22 ## 调整
23 23
24 修复用户登录查找方式
24 现在,可以返回自己的用户登录模型,而非固定的继承于IUserFaceInfo的模型
25 25
26 ## 新增
26 ## 新增
27 27
28
28
29 29
30 ## 严重
30 ## 严重
31 31
32
33 </PackageReleaseNotes>
32
33 </PackageReleaseNotes>
34 34 <NeutralLanguage>zh-CN</NeutralLanguage>
35 35 <PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
36 36 <Version>$(Version)</Version>