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);
            }
        }
Example #2
0
        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);
            }
        }
Example #3
0
        protected void Application_AuthenticateRequest()

        {
            CustomFormsAuthentication.AuthenticateRequestDecryptCustomFormsAuthenticationTicket(Context);
        }
Example #4
0
 public ActionResult Logout()
 {
     CustomFormsAuthentication.Logout();
     return(RedirectToAction("Index", "Home", new { Area = "" }));
 }
Example #5
0
 public void SignOut()
 {
     CustomFormsAuthentication.SignOut();
 }
 protected void asplnkLogout_OnClick(object sender, EventArgs e)
 {
     CustomFormsAuthentication.SignOut();
     CustomFormsAuthentication.RedirectToLoginPage();
 }
Example #7
0
 // ReSharper disable InconsistentNaming
 protected void Application_AuthenticateRequest()
 // ReSharper restore InconsistentNaming
 {
     CustomFormsAuthentication.AuthenticateRequestDecryptCustomFormsAuthenticationTicket(Context);
 }
Example #8
0
 public ActionResult Logout()
 {
     CustomFormsAuthentication.Logout();
     return(RedirectToAction("Login", "User"));
 }