改名
This commit is contained in:
1 parent
d23544c9d8
commit
5135ab04ec
1 file changed
@@ -0,0 +1,42 @@
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using WalkingTec.Mvvm.Core;
|
||||
|
||||
namespace HHWMS.Web.Support;
|
||||
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
public class UserSessionManager
|
||||
{
|
||||
private static ConcurrentDictionary<string, string> userSessions = new ConcurrentDictionary<string, string>();
|
||||
|
||||
public static void AddUserSession(string userId, string sessionId)
|
||||
{
|
||||
userSessions[userId.ToLower()] = sessionId;
|
||||
}
|
||||
|
||||
public static void RemoveUserSession(string userId)
|
||||
{
|
||||
userSessions.TryRemove(userId, out _);
|
||||
}
|
||||
|
||||
public static bool IsUserSessionValid(string userId, string sessionId)
|
||||
{
|
||||
return userSessions.TryGetValue(userId.ToLower(), out var storedSessionId) && storedSessionId == sessionId;
|
||||
}
|
||||
|
||||
public static bool IsUserSignined(string userId)
|
||||
{
|
||||
return userSessions.ContainsKey(userId);
|
||||
}
|
||||
|
||||
public static void KickUser(string userId)
|
||||
{
|
||||
userSessions.TryRemove(userId, out _);
|
||||
}
|
||||
|
||||
public static ConcurrentDictionary<string, string> AllSignined()
|
||||
{
|
||||
return userSessions;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user