Beispiel #1
0
        protected void loginControl_Login(object sender, EventArgs e)
        {
            RaiseEvent("Login.aspx#Login", sender, e);

            var args = e as LoginEventArgs;
            User user = null;
            bool allowLogin;

            using (var dataSource = NewDataSource())
            {
                using (var userAccountLogic = new UserAccountLogic(dataSource))
                {
                    userAccountLogic.UserNotFound += UserNotFound;
                    userAccountLogic.InvalidPassword += InvalidPassword;

                    allowLogin = userAccountLogic.AllowLogin(args.UserName, args.Password, ref user);
                }
            }

            if (allowLogin)
            {
                UserHandle.Current.CurrentUser = user;
                RaiseEvent("Login.aspx#LoginSuccessful", sender, e);
                if (!string.IsNullOrEmpty(ReturnUrl))
                    Response.Redirect(string.Format("{0}",ReturnUrl));
                Response.Redirect("UserHome.aspx");
            }
        }