public ActionResult Index([ModelBinder(typeof(UserDataModelBinder))] string userData) { var tuple = UserLoginHelper.GetUserData(userData); AuthenticateHelper.SetTicket(tuple.Item1.ToString(), null, 0, tuple.Item2); return(Redirect("/Home/Index")); }
public ActionResult Login(LoginViewModel viewModel) { if (!UserLoginHelper.Login(viewModel.UserId, viewModel.UserPwd)) { ModelState.AddModelError("", "账号或密码不正确"); return(View()); } return(RedirectToAction("SelectTest")); }
public string Login(string keyword, string password) { try { var account = AdminLoginHelper.AdminLogin(keyword, password) != null ? 1 :0; if (LoginOnlyAdmin == "false" && account == 0) { account = UserLoginHelper.UserLogin(keyword, password) != null ? 1 : 0; } //var account = AdminLoginHelper.AdminLogin(keyword, password); if (account == 0) { ReturnData result = new ReturnData(500, "登录失败"); return(result.ToJson()); } else { ReturnData result = new ReturnData(0, "登录成功"); var admin = PersonalFramework.Service.AdminLoginHelper.CurrentUser(); //记录操作日志,写进操作日志中 var log = new ActionLog(); log.ActionContent = "管理员登录"; log.CreateTime = DateTime.Now; log.IP = IPHelper.GetClientIp(); log.Location = "Login/Login"; log.RequestData = Request.Form.ToString(); log.Platform = "后台"; log.Source = Request.HttpMethod; log.RequestUrl = Request.Url.AbsoluteUri; if (admin != null) { log.UID = admin.ID; log.UserName = admin.AdminName; } DataContext context = new DataContext(); context.ActionLog.Add(log); context.SaveChanges(); return(result.ToJson()); } } catch (Exception ex) { ReturnData result = new ReturnData(500, ex.Message); return(result.ToJson()); } }
public string login(string name, string pw) { long id = 0; // avnänds ej en nu bool loginR = false; using (var con = hemSida.Models.ModelBass.getCon()) { loginR = UserLoginHelper.Login(con, name, pw, ref id); } if (loginR) FormsAuthentication.SetAuthCookie(name, false); var jp = new JsonResponse(); jp.result = loginR; return jp.ToString(); }
public Login() { InitializeComponent(); userManager = UserManager.GetINSTANCE(); loginHelper = new UserLoginHelper(new UserDbRepository(new ChatContext())); }
public ActionResult Logout() { UserLoginHelper.Logout(); return(RedirectToAction("Login", "Home")); }
/// <summary> /// 啊飒飒大王的 /// </summary> /// <returns></returns> public ActionResult LoginOut() { UserLoginHelper.UserLogout(); return(RedirectToAction("index")); }
public async Task <IActionResult> Login([FromServices] SignInManager <ApplicationUser> signInManager, UserLoginHelper author) { if (!ModelState.IsValid) { return(RedirectToAction("Index")); } this._signinManager = signInManager; var newUser = await _userManager.FindByNameAsync(author.Email); if (newUser == null) { return(RedirectToAction("Index")); } var res = await _signinManager.PasswordSignInAsync(newUser, author.Password, false, false); if (res.Succeeded) { return(RedirectToAction("Protected", "Protected")); } return(RedirectToAction("Index")); }
public async Task <IActionResult> SignUp([FromServices] SignInManager <ApplicationUser> signInManager, UserLoginHelper author) { if (!ModelState.IsValid) { return(RedirectToAction("Index")); } this._signinManager = signInManager; var newUser = new ApplicationUser() { Email = author.Email, UserName = author.Email }; var res = await _userManager.CreateAsync(newUser, author.Password); //var str = _userManager.GetValidTwoFactorProvidersAsync(newUser); if (res.Succeeded) { // await _signinManager.SignInAsync(newUser, false); var code = _userManager.GenerateEmailConfirmationTokenAsync(newUser); var url = Url.Action("ConfirmEmail", new { userId = newUser.Id, code = code.Result }); await _emailService.SendAsync(newUser.Email, "Confirm Your email", $"<a href = '{url}'>Confirm</a>"); //return RedirectToAction("Protected", "Protected"); } return(RedirectToAction("Index")); }