protected void aspxbtnAuthorize_OnClick(object sender, EventArgs e) { try { var user = ADORepository.Users().FirstOrDefault(x => x.Login == aspxtbLogin.GetValue <string>()); new AuthorizationUserValidator().Validate(user, aspxtbPassword.GetValue <string>()); var userSessionGuid = Guid.NewGuid().ToString(); CustomFormsAuthentication.SetAuthCookie(user.Id.ToString(CultureInfo.InvariantCulture), true, userSessionGuid); Response.Redirect("~/"); } catch (Exception exception) { ShowError(exception); } }
public User IsAuthenticatedUser(LoginUserModel model) { try { var user = _userService.GetByEmail(model.Email); if (user != null) { if (!user.IsEmailVerified) { executeMessage = "Please verify your email first"; return(null); } if (String.Compare(CustomCrypto.Hash(model.Password), user.Password) == 0) { CustomFormsAuthentication.Login(user, model.RememberMe); executeMessage = ""; return(user); } else { executeMessage = "Invalid user email or password"; return(null); } } else { executeMessage = "Invalid user email or password"; return(null); } } catch (Exception ex) { Console.WriteLine(ex); executeMessage = ex.Message; return(null); } }
protected void Application_AuthenticateRequest() { CustomFormsAuthentication.AuthenticateRequestDecryptCustomFormsAuthenticationTicket(Context); }
public ActionResult Logout() { CustomFormsAuthentication.Logout(); return(RedirectToAction("Index", "Home", new { Area = "" })); }
public void SignOut() { CustomFormsAuthentication.SignOut(); }
protected void asplnkLogout_OnClick(object sender, EventArgs e) { CustomFormsAuthentication.SignOut(); CustomFormsAuthentication.RedirectToLoginPage(); }
// ReSharper disable InconsistentNaming protected void Application_AuthenticateRequest() // ReSharper restore InconsistentNaming { CustomFormsAuthentication.AuthenticateRequestDecryptCustomFormsAuthenticationTicket(Context); }
public ActionResult Logout() { CustomFormsAuthentication.Logout(); return(RedirectToAction("Login", "User")); }