Revert "添加在线用户管理,同一账号只允许一台设备登陆。"

This reverts commit a777e04e83.
This commit is contained in:
zhougf committed 2024-07-08 14:08:02 +08:00
1 parent a777e04e83
commit 4c99666b75
11 files changed
+10 -192

No files matched your search

-16
View File
@@ -3,15 +3,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using HHWMS.Web.Support;
using HHWMS.Web.ViewModels.HomeVMs;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
@@ -157,18 +153,6 @@ namespace HHWMS.Web.Controllers
return JsonMore("No Data");
}
[Public]
public IActionResult CheckLogin()
{
return Ok();
}
[Public]
public IActionResult BeforeLogin(LoginVM vm)
{
return JsonMore(UserSessionManager.AllSignined().ToList());
}
//[AllowAnonymous]
//public github GetGithubInfo()
//{
+2 -27
View File
@@ -14,11 +14,6 @@ using WalkingTec.Mvvm.Mvc.Admin.ViewModels.FrameworkUserVms;
using HHWMS.Web.ViewModels.HomeVMs;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HHWMS.Web.Support;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Caching.Distributed;
using WalkingTec.Mvvm.Core.Support.Quartz;
namespace HHWMS.Web.Controllers
{
@@ -38,7 +33,7 @@ namespace HHWMS.Web.Controllers
}
return View(vm);
}
[Public]
[HttpPost]
public async Task<ActionResult> Login(LoginVM vm)
@@ -52,9 +47,7 @@ namespace HHWMS.Web.Controllers
return View(vm);
}
}*/
var user = Wtm.DoLogin(vm.ITCode, vm.Password, vm.Tenant);
if (user == null)
{
vm.MSD.AddModelError("", Localizer["Sys.LoginFailed"]);
@@ -62,13 +55,6 @@ namespace HHWMS.Web.Controllers
}
else
{
var bb = UserSessionManager.IsUserSignined(user.Name);
if (bb)
{
// 踢人下线
await KickUser(user.Name);
}
//其他属性可以通过user.Attributes["aaa"] = "bbb"方式赋值
Wtm.LoginUserInfo = user;
string url = string.Empty;
@@ -91,9 +77,7 @@ namespace HHWMS.Web.Controllers
};
}
var principal = user.CreatePrincipal();
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, properties);
UserSessionManager.AddUserSession(user.Name,principal.Claims.First(c => c.Type == "SessionId").Value);
return Redirect(HttpUtility.UrlDecode(url));
}
}
@@ -136,7 +120,6 @@ namespace HHWMS.Web.Controllers
[ActionDescription("Logout")]
public async Task Logout()
{
UserSessionManager.RemoveUserSession(Wtm.LoginUserInfo.Name);
HttpContext.Session.Clear();
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
if (ConfigInfo.HasMainHost == false || Wtm.LoginUserInfo?.CurrentTenant != null)
@@ -149,15 +132,7 @@ namespace HHWMS.Web.Controllers
HttpContext.Response.Redirect(ConfigInfo.MainHost);
}
}
[AllRights]
public async Task<IActionResult> KickUser(string ITcode)
{
UserSessionManager.KickUser(ITcode);
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
return Ok();
}
[AllRights]
[ActionDescription("ChangePassword")]
public ActionResult ChangePassword()