public ActionResult Login() { string accountId = AppCookieHelper.Get <string>(); if (!string.IsNullOrEmpty(accountId)) { return(RedirectToAction("Index", "Dashboard")); } return(View()); }
public AlertMessage Login(LoginViewModel model) { AlertMessage alert = new AlertMessage(); if (_userManager == null) { alert.Text = StaticMessage.ERR_GLOBAL; return(alert); } //_logger.Write("info", DateTime.Now, "tes Login", model.Username); TUser user = null; #if DEBUG var sss = _userManager.FindByNameAsync(model.Username); //user = GetUserByNIK(model.Username.Trim()); user = GetUserById(sss.Result.Id); #else var sss = _userManager.FindAsync(model.Username, model.Password); if (sss.Result == null) { alert.Text = string.Format(StaticMessage.ERR_LOGIN_FAILED); return(alert); } user = GetUserById(sss.Result.Id); #endif if (user == null) { alert.Text = StaticMessage.ERR_USER_NOT_FOUND; return(alert); } if (!(user.IsActive != (int?)null && user.IsActive.Value == 1)) { alert.Text = StaticMessage.ERR_USER_INACTIVE; return(alert); } #region set data to cookie AppCookieHelper.Set(sss.Result.Id, false /*model.IsRemember*/, model.Username); #endregion alert.Status = 1; return(alert); }
public UserAuthenticated GetUserAuth() { string strUserId = AppCookieHelper.Get <string>(); if (string.IsNullOrEmpty(strUserId)) { return(null); } Guid userId = Guid.Parse(strUserId); TUser user = GetUserById(userId); return(GetUserAuth(user)); }
public IActionResult Login(LoginViewModel loginVM) { ViewBag.ErrorMessage = null; if (loginVM.Username.Equals(_AdminPass["admin"]) && loginVM.Password.Equals(_AdminPass["pass"])) { AppCookieHelper.Set(_AdminPass, "admin", loginVM.IsRemember, "AssigningTasksSample", this.HttpContext); return(RedirectPermanent(SiteHelper.GetBaseUrl(HttpContext.Request) + "/Assignee/Simulation")); } return(View()); }
public IActionResult Logout() { AppCookieHelper.LogOut(this.HttpContext); return(RedirectPermanent(SiteHelper.GetBaseUrl(HttpContext.Request) + "/Account/Login")); }
public void Logout() { AppCookieHelper.Remove(); }