更新框架
This commit is contained in:
1 parent
ef50fa0620
commit
84b28f9672
72 files changed
+2222
-282
No files matched your search
@@ -0,0 +1,16 @@
|
||||
namespace Store.Management.Api.Authentication;
|
||||
|
||||
/// <summary>会话仅保存在内存中,不将密码或 Token 写入配置与日志。</summary>
|
||||
public sealed class TokenSession
|
||||
{
|
||||
private string? _token;
|
||||
public bool IsAuthenticated => Volatile.Read(ref _token) is not null;
|
||||
internal string? Token => Volatile.Read(ref _token);
|
||||
internal void Set(string token) => Interlocked.Exchange(ref _token, token);
|
||||
public void Clear() => Interlocked.Exchange(ref _token, null);
|
||||
// 旧请求的 401 不应清除重新登录后建立的新会话。
|
||||
internal void ClearIfCurrent(string? token)
|
||||
{
|
||||
if (token is not null) Interlocked.CompareExchange(ref _token, null, token);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user