private void AuthenticateIP()
        {
            dto.Login inLoginDto = GetPageValues();

            LoginFacade facade = new LoginFacade();

            dto.Login outLoginDto = facade.AuthenticateIP(inLoginDto);

            if (outLoginDto != null)
            {
                // For this sample, always set the persist flag to false.
                if (Request.QueryString["returnurl"] != null)
                {
                    FormsAuthentication.RedirectFromLoginPage(outLoginDto.EmailAddress, false);
                }
                else
                {
                    FormsAuthentication.SetAuthCookie(outLoginDto.EmailAddress, false);

                    Response.Redirect(Pages.Home, false);
                }
            }
            else
            {
                LblIPAddress.Text = inLoginDto.IPAddress;
            }
        }
        private dto.Login GetPageValues()
        {
            dto.Login loginDto = new dto.Login();

            loginDto.IPAddress = Request.ServerVariables["REMOTE_ADDR"];

            return(loginDto);
        }
Beispiel #3
0
        private void btnLogin_OnClick(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                dto.Login inLoginDto = GetPageValues();

                LoginFacade facade = new LoginFacade();

                ActionStatus status = facade.AuthenticateUser(inLoginDto);

                // Here's the call to validate the user's credentials and redirect to the appropriate
                // page if valid.
                if (status.IsSuccessful)
                {
                    // For this sample, always set the persist flag to false.
                    if (Request.QueryString["returnurl"] != null)
                    {
                        FormsAuthentication.RedirectFromLoginPage(inLoginDto.EmailAddress, false);
                    }
                    else
                    {
                        FormsAuthentication.SetAuthCookie(inLoginDto.EmailAddress, false);

                        Response.Redirect(Pages.Home, false);
                    }
                }
                else
                {
                    lblErrors.Text = GetFormattedMessages(status);
                }
            }
            else
            {
                VsLogin.Visible = true;
            }
        }