public ActionResult Login(LoginVM vm) { if (ConfigInfo.IsQuickDebug == false) { var verifyCode = HttpContext.Session.Get <string>("verify_code"); if (string.IsNullOrEmpty(verifyCode) || verifyCode.ToLower() != vm.VerifyCode.ToLower()) { vm.MSD.AddModelError("", "验证码不正确"); return(View(vm)); } } var user = vm.DoLogin(); if (user == null) { return(View(vm)); } else { LoginUserInfo = user; string url = ""; if (!string.IsNullOrEmpty(vm.Redirect)) { url = vm.Redirect; } else { url = "/"; } return(Redirect(HttpUtility.UrlDecode(url))); } }
public ActionResult Login(LoginVM vm) { if (vm.Code == string.Empty || vm.Code != (string)MemoryCacheTime.GetCacheValue(ImageCodeHelper.CacheKey + vm.UUId)) { return(View(CreateVM <LoginVM>())); } var user = vm.DoLogin(); if (user == null) { return(View(vm)); } else { LoginUserInfo = user; string url = ""; if (!string.IsNullOrEmpty(vm.Redirect)) { url = vm.Redirect; } else { url = "/"; } return(Redirect(HttpUtility.UrlDecode(url))); } }
public async Task <ActionResult> Login(LoginVM vm) { //if (ConfigInfo.IsQuickDebug == false) //{ // var verifyCode = HttpContext.Session.Get<string>("verify_code"); // if (string.IsNullOrEmpty(verifyCode) || verifyCode.ToLower() != vm.VerifyCode.ToLower()) // { // vm.MSD.AddModelError("", "验证码不正确"); // return View(vm); // } //} var user = vm.DoLogin(); if (user == null) { return(View(vm)); } else { LoginUserInfo = user; string url = string.Empty; if (!string.IsNullOrEmpty(vm.Redirect)) { url = vm.Redirect; } else { url = "/"; } AuthenticationProperties properties = null; // if (vm.RememberLogin) //{ properties = new AuthenticationProperties { IsPersistent = true, ExpiresUtc = DateTimeOffset.UtcNow.Add(TimeSpan.FromDays(30)) }; //} var claims = new[] { new Claim("OrganCode", user.Memo) }; var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var principal = user.CreatePrincipal(); principal.AddIdentity(claimsIdentity); // 在上面注册AddAuthentication时,指定了默认的Scheme,在这里便可以不再指定Scheme。 await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, properties); return(Redirect(HttpUtility.UrlDecode(url))); } }
public async Task <ActionResult> Login(LoginVM vm) { //if (ConfigInfo.IsQuickDebug == false) //{ // var verifyCode = HttpContext.Session.Get<string>("verify_code"); // if (string.IsNullOrEmpty(verifyCode) || verifyCode.ToLower() != vm.VerifyCode.ToLower()) // { // vm.MSD.AddModelError("", Localizer["Login.ValidationFail"]); // return View(vm); // } //} var user = vm.DoLogin(); if (user == null) { return(View(vm)); } else { LoginUserInfo = user; string url = string.Empty; if (!string.IsNullOrEmpty(vm.Redirect)) { url = vm.Redirect; } else { if (DC.Set <user>().Include("UserRoles").Where(r => r.ID == LoginUserInfo.Id).FirstOrDefault().UserRoles.FirstOrDefault().Role.RoleName == "领用人") { url = "/#/ShipOrder/ship_pop/Index"; } else { url = "/#/INV/inventorySum/Index"; } } AuthenticationProperties properties = null; if (vm.RememberLogin) { properties = new AuthenticationProperties { IsPersistent = true, ExpiresUtc = DateTimeOffset.UtcNow.Add(TimeSpan.FromDays(30)) }; } var principal = user.CreatePrincipal(); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, properties); return(Redirect(HttpUtility.UrlDecode(url))); } }
public async Task <ActionResult> Login(LoginVM vm) { if (ConfigInfo.IsQuickDebug == false) { var verifyCode = HttpContext.Session.Get <string>("verify_code"); if (string.IsNullOrEmpty(verifyCode) || verifyCode.ToLower() != vm.VerifyCode.ToLower()) { vm.MSD.AddModelError("", Localizer["Login.ValidationFail"]); return(View(vm)); } } var user = vm.DoLogin(); if (user == null) { return(View(vm)); } else { LoginUserInfo = user; string url = string.Empty; if (!string.IsNullOrEmpty(vm.Redirect)) { url = vm.Redirect; } else { url = "/"; } AuthenticationProperties properties = null; if (vm.RememberLogin) { properties = new AuthenticationProperties { IsPersistent = true, ExpiresUtc = DateTimeOffset.UtcNow.Add(TimeSpan.FromDays(30)) }; } var principal = user.CreatePrincipal(); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, properties); return(Redirect(HttpUtility.UrlDecode(url))); } }
public async Task <ActionResult> Login(LoginVM vm) { //if (ConfigInfo.IsQuickDebug == false) //{ // var verifyCode = HttpContext.Session.Get<string>("verify_code"); // if (string.IsNullOrEmpty(verifyCode) || verifyCode.ToLower() != vm.VerifyCode.ToLower()) // { // vm.MSD.AddModelError("", "验证码不正确"); // return View(vm); // } //} var user = vm.DoLogin(); if (user == null) { return(View(vm)); } else { LoginUserInfo = user; string url = string.Empty; if (!string.IsNullOrEmpty(vm.Redirect)) { url = vm.Redirect; } else { url = "/"; } AuthenticationProperties properties = null; if (vm.RememberLogin) { properties = new AuthenticationProperties { IsPersistent = true, ExpiresUtc = DateTimeOffset.UtcNow.Add(TimeSpan.FromDays(30)) }; } return(Redirect(HttpUtility.UrlDecode(url))); } }
public async Task <ActionResult> Login(LoginVM vm) { if (ConfigInfo.IsQuickDebug == false) { } var user = vm.DoLogin(); if (user == null) { return(View(vm)); } else { LoginUserInfo = user; string url = string.Empty; if (!string.IsNullOrEmpty(vm.Redirect)) { url = vm.Redirect; } else { url = "/"; } AuthenticationProperties properties = null; if (vm.RememberLogin) { properties = new AuthenticationProperties { IsPersistent = true, ExpiresUtc = DateTimeOffset.UtcNow.Add(TimeSpan.FromDays(30)) }; } var principal = user.CreatePrincipal(); // 在上面注册AddAuthentication时,指定了默认的Scheme,在这里便可以不再指定Scheme。 await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, properties); return(Redirect(HttpUtility.UrlDecode(url))); } }
public ActionResult Login(LoginVM vm) { var user = vm.DoLogin(); if (user == null) { return(View(vm)); } else { LoginUserInfo = user; string url = ""; if (!string.IsNullOrEmpty(vm.Redirect)) { url = vm.Redirect; } else { url = "/"; } return(Redirect(HttpUtility.UrlDecode(url))); } }
public ActionResult Login(LoginVM vm) { var user = vm.DoLogin(); if (user == null) { return(PartialView(vm)); } else { LoginUserInfo = user; string url = ""; if (!string.IsNullOrEmpty(vm.Redirect)) { url = vm.Redirect; } else { url = "/"; } url = Configs.VirtualDir + url; return(Content("<script>window.location.replace('" + HttpUtility.UrlDecode(url) + "');</script>")); } }
public void Execute(object parameter) { LoginVM.DoLogin((System.Windows.Window)parameter); }