diff --git a/Communications/SimApiLoginItem.cs b/Communications/SimApiLoginItem.cs
index 8c703ec..f336b97 100644
--- a/Communications/SimApiLoginItem.cs
+++ b/Communications/SimApiLoginItem.cs
@@ -1,6 +1,8 @@
-namespace SimApi.Communications;
+using System.Collections.Generic;
+
+namespace SimApi.Communications;
///
/// 登录信息中间件
///
-public record SimApiLoginItem(string Id, string[] Type);
\ No newline at end of file
+public record SimApiLoginItem(string Id, string[] Type,Dictionary Meta = null);
\ No newline at end of file
diff --git a/Controllers/SimApiCommonController.cs b/Controllers/SimApiCommonController.cs
index c8167d5..3b8e35f 100644
--- a/Controllers/SimApiCommonController.cs
+++ b/Controllers/SimApiCommonController.cs
@@ -51,4 +51,10 @@ public class SimApiCommonController(SimApiAuth auth) : SimApiBaseController
auth.Logout(token!);
return new SimApiBaseResponse();
}
+
+ [HttpPost("/logined"),SimApiAuth]
+ public SimApiBaseResponse UserInfo()
+ {
+ return new SimApiBaseResponse(LoginInfo);
+ }
}
\ No newline at end of file
diff --git a/Helpers/SimApiAuth.cs b/Helpers/SimApiAuth.cs
index 25a34dd..fc546a3 100644
--- a/Helpers/SimApiAuth.cs
+++ b/Helpers/SimApiAuth.cs
@@ -1,5 +1,6 @@
#nullable enable
using System;
+using System.Collections.Generic;
using System.Text.Json;
using Microsoft.Extensions.Caching.Distributed;
using SimApi.Communications;
@@ -16,11 +17,12 @@ public class SimApiAuth(IDistributedCache cache)
///
///
///
+ ///
///
///
- public string Login(string id, string type = "user", string token = null)
+ public string Login(string id, Dictionary? meta = null, string type = "user", string? token = null)
{
- return Login(id, new[] { type }, token);
+ return Login(id, meta, new[] { type }, token);
}
///
@@ -28,16 +30,33 @@ public class SimApiAuth(IDistributedCache cache)
///
///
///
+ ///
///
///
- public string Login(string id, string[] type, string uuid = null)
+ // ReSharper disable once MemberCanBePrivate.Global
+ public string Login(string id, Dictionary? meta, string[] type, string? uuid = null)
{
uuid ??= Guid.NewGuid().ToString();
- var loginItem = new SimApiLoginItem(id, type);
+ var loginItem = new SimApiLoginItem(id, type, meta);
cache.SetString(uuid, JsonSerializer.Serialize(loginItem));
return uuid;
}
+ ///
+ /// 设置登录的Meta信息
+ ///
+ ///
+ ///
+ ///
+ public bool SetMeta(string token, Dictionary meta)
+ {
+ var login = GetLogin(token);
+ if (login == null) { return false; }
+ var newLogin = new SimApiLoginItem(login.Id, login.Type, login.Meta);
+ cache.SetString(token,JsonSerializer.Serialize(newLogin));
+ return true;
+ }
+
///
/// 获取登陆信息
///
diff --git a/Helpers/SimApiStorage.cs b/Helpers/SimApiStorage.cs
index 96f9d4c..84c45ab 100644
--- a/Helpers/SimApiStorage.cs
+++ b/Helpers/SimApiStorage.cs
@@ -14,7 +14,7 @@ public class SimApiStorage
private string ServeUrl { get; }
- private string Bucket { get; }
+ public string Bucket { get; }
private IHttpContextAccessor HttpContextAccessor { get; }