public IActionResult Login(string returnUrl = "") { var model = new VM_Login { ReturnUrl = returnUrl }; return(View(model)); }
public IActionResult Login(string returnUrl = "") { var model = new VM_Login { ReturnUrl = returnUrl }; ViewBag.RegisterMessage = TempData["RegisterMessage"]; return(View(model)); }
public async Task <IActionResult> Login(VM_Login account) { if (ModelState.IsValid) { try { var member = _services.GetUser(account); if (member != null) { var userPrincipal = Helper.GenerateIdentity(member); var props = new AuthenticationProperties { IsPersistent = account.IsRememberMe }; //sign in await HttpContext.SignInAsync( scheme : "MyCookieScheme", principal : userPrincipal, properties : props ); if (!string.IsNullOrEmpty(account.ReturnUrl) && Url.IsLocalUrl(account.ReturnUrl)) { return(Redirect(account.ReturnUrl)); } else { //client if (member.LevelId == 3) { return(RedirectToAction("ClientRealEstateList", "RealEstate")); } return(RedirectToAction("CustomerConfirmList", "RealEstate")); } } else { ViewBag.Message = "Sai tài khoản hoặc mật khẩu!"; } } catch (Exception) { throw; } } return(View(account)); }
public ActionResult Login(VM_Login admin) { if (ModelState.IsValid) { var currentAdmin = _context.Admins .FirstOrDefault(x => x.Username.ToLower() == admin.Username.ToLower() && x.Password == admin.Password); if (currentAdmin == null) { ModelState.AddModelError("", "Username or Password is not correct."); } else { return(RedirectToAction("Index", "ManageProduct")); } } return(View("Index")); }
public async Task <IActionResult> Login(VM_Login account, string returnUrl) { if (ModelState.IsValid) { var member = _services.GetUser(account); if (member != null) { var userPrincipal = Helper.GenerateIdentity(member); var props = new AuthenticationProperties { IsPersistent = account.IsRememberMe }; //sign in await HttpContext.SignInAsync( scheme : "MyCookieScheme", principal : userPrincipal, properties : props ); if (!string.IsNullOrEmpty(returnUrl) && Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } } else { ViewBag.ErrorMessage = "Invalid user or password!"; } } return(View(account)); }
public OperationResult <LoginInfo> Login(VM_Login obj) { return(Controller.Login(obj.Username, obj.Password)); }
public Login() { InitializeComponent(); login = new VM_Login(); }
public W_Login() { InitializeComponent(); base.DataContext = _viewModel = new VM_Login(); _viewModel.LoginWindowDelegate = LoginWindowsCommand; }
public Agent GetUser(VM_Login login) { var user = _dbContext.Agent.SingleOrDefault(x => x.LoginName == login.LoginName && x.Password == login.Password); return(user); }