public InicioSesionPageViewModel(INavigationService navigationService, IUserDialogs userDialogs) : base(navigationService) { _navigationService = navigationService; _userDialogs = userDialogs; LoginMD = new LoginMD(); IngresarCommand = new DelegateCommand(Ingresar); }
public IActionResult Login() { var data = new LoginMD(); ModelState.Clear(); return(View(data)); }
public ActionResult Login(LoginMD Data) { RepositoryUser repo = new RepositoryUser(); UserViewModel user = repo.GetUserViewModel(new User { Phone = Data.Phone }); // 驗證帳號 if (user == null) { TempData["ErrMsg"] = "登入失敗 : 帳號錯誤"; return(RedirectToAction("Login", "Home")); } // 驗證密碼 if (!Data.UserPwd.Equals(user.UserPwd)) { TempData["ErrMsg"] = "登入失敗 : 密碼錯誤"; return(RedirectToAction("Login", "Home")); } FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, user.Name, DateTime.Now, DateTime.Now.AddMinutes(30), true, JsonConvert.SerializeObject(new AuthModel { ID = user.RecordID, Name = user.Name, Phone = user.Phone, AuthLevel = user.AuthLevel }), FormsAuthentication.FormsCookiePath ); string encTicket = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket); cookie.HttpOnly = true; Response.Cookies.Add(cookie); return(RedirectToAction("Index", "Home")); }
public IActionResult Login(LoginMD metaData) { if (string.IsNullOrEmpty(metaData.Account)) { ViewBag.ErrorMessage = $"請輸入帳號"; return(View(metaData)); } if (string.IsNullOrEmpty(metaData.Password)) { ViewBag.ErrorMessage = $"請輸入密碼"; return(View(metaData)); } var administrator = _context.Administrators.Single(x => x.Account.Equals(metaData.Account, StringComparison.CurrentCultureIgnoreCase)); if (administrator == null) { ViewBag.ErrorMessage = $"帳號錯誤"; return(View(metaData)); } if (!administrator.Password.Equals(metaData.Password)) { ViewBag.ErrorMessage = $"密碼錯誤"; return(View(metaData)); } if (administrator.Status != AccountStatusTypeEnum.Normal) { ViewBag.ErrorMessage = $"帳號狀態異常"; return(View(metaData)); } return(RedirectToAction("Index", "Member")); }
public ActionResult Login() { LoginMD data = new LoginMD(); return(View(data)); }