コード例 #1
0
        /// <summary>
        /// Sign In Button click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSignIn_Click(object sender, EventArgs e)
        {
            LogHelper.Log(Logger.Application, LogLevel.Info, "SignIn - User Login entry");

            if (!CookieHelper.CheckIfCookiesSupported(Request))
            {
                LogHelper.Log(Logger.Application, LogLevel.Info, "SignIn - browser cookie supported");
                Response.Redirect(PageLink.CookiesNotAllowedPage);
                return;
            }

            txtEmailAddress.Value = txtEmailAddress.Value.Trim().ToLower();
            txtCKPassword.Value   = FormatHelper.CleanUpInvalidPasswordCharacters(txtCKPassword.Value);

            if (!ValidateInputs())
            {
                divMessage.Visible = true;
                var localResourceObject = GetLocalResourceObject("MessageRequiredField");
                if (localResourceObject != null)
                {
                    ltlMessage.Text = localResourceObject.ToString();
                    LogHelper.Log(Logger.Application, LogLevel.Warn, "SignIn - " + localResourceObject + "");
                }
                ScriptManager.RegisterStartupScript(this, GetType(), "Pop", "showModal();", true);
                return;
            }

            if (UserController.Validate(txtEmailAddress.Value, txtCKPassword.Value))
            {
                if (
                    SecurityHelper.CheckForPasswordChangeNotification(UserController.GetByUserName(txtEmailAddress.Value)))
                {
                    FormsAuthentication.SetAuthCookie(txtEmailAddress.Value, chkRememberMe.Checked);
                    Utilities.SetCrossPageMessage(Shared.ChangePasswordNotificationMessage, MessageType.Information);
                    Response.Redirect(PageLink.ChangePasswordPageWithReturnURL.Replace("[ReturnURL]",
                                                                                       PageLink.DefaultPage));
                }
                else
                {
                    FormsAuthentication.RedirectFromLoginPage(txtEmailAddress.Value, chkRememberMe.Checked);
                    LogHelper.Log(Logger.Application, LogLevel.Info, "SignIn - user validation successful");
                }
            }
            else
            {
                divMessage.Visible = true;
                var localResourceObject = GetLocalResourceObject("MessageLoginError");
                if (localResourceObject != null)
                {
                    ltlMessage.Text = localResourceObject.ToString();
                    LogHelper.Log(Logger.Application, LogLevel.Error, "SignIn - " + localResourceObject + "");
                }
                ScriptManager.RegisterStartupScript(this, GetType(), "Pop", "showModal();", true);
            }

            LogHelper.Log(Logger.Application, LogLevel.Info, "SignIn - User Login ended");
        }