Пример #1
0
        protected void LogIn(object sender, EventArgs e)
        {
            if (IsValid)
            {
                // Valide a senha de usuário
                //var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
                //var signinManager = Context.GetOwinContext().GetUserManager<ApplicationSignInManager>();

                // Isso não conta falhas de logon para bloqueio de conta
                // Para habilitar falhas de senha para acionar o bloqueio, mude para shouldLockout: true
                //var result = signinManager.PasswordSignIn(Email.Text, Password.Text, RememberMe.Checked, shouldLockout: false);
                //var result = signinManager.PasswordSignIn(Email.Text, Password.Text, false, shouldLockout: false);

                //switch (result)
                //{
                //    case SignInStatus.Success:
                //        IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
                //        break;
                //    case SignInStatus.LockedOut:
                //        Response.Redirect("/Account/Lockout");
                //        break;
                //case SignInStatus.RequiresVerification:
                //    Response.Redirect(String.Format("/Account/TwoFactorAuthenticationSignIn?ReturnUrl={0}&RememberMe={1}",
                //                                    Request.QueryString["ReturnUrl"],
                //                                    RememberMe.Checked),
                //                      true);
                //    break;
                //case SignInStatus.Failure:
                //default:
                //    FailureText.Text = "Tentativa de logon inválida";
                //    ErrorMessage.Visible = true;
                //    break;
                //}
                User             user = new User();
                SampleManagerWeb smw  = new SampleManagerWeb();
                user = smw.LoginSMUSer(Email.Text, Password.Text);

                if (user.Login.Equals(""))
                {
                    //not logged in
                    FailureText.Text     = "Logon Failed";
                    ErrorMessage.Visible = true;
                }
                else
                {
                    //logged in
                    Session.Add("user", user);
                    Response.Redirect("/Default.aspx");
                }
            }
        }