Ejemplo n.º 1
0
        /// <summary>
        /// Handles the Authenticate event of the LoginCtrl control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.AuthenticateEventArgs"/> instance containing the event data.</param>
        void LoginCtrl_Authenticate(object sender, AuthenticateEventArgs e)
        {
            string appName = ((TextBox)LoginCtrl.FindControl("Application")).Text;
            AppDto dto     = AppContext.Current.GetApplicationDto(appName);

            // If application does not exists or is not activa, prevent login
            if (dto == null || dto.Application.Count == 0 || !dto.Application[0].IsActive)
            {
                LogManager.WriteLog("LOGIN", LoginCtrl.UserName, "login.aspx", "Commerce Manager", "SYSTEM", "Application name is incorrect.", false);
                LoginCtrl.FailureText = "Login failed. Please try again.";
                return;
            }

            Membership.Provider.ApplicationName = appName;

            if (Membership.ValidateUser(LoginCtrl.UserName, LoginCtrl.Password))
            {
                CHelper.CreateAuthenticationCookie(LoginCtrl.UserName, appName, LoginCtrl.RememberMeSet);
                string url = FormsAuthentication.GetRedirectUrl(LoginCtrl.UserName, LoginCtrl.RememberMeSet);
                LogManager.WriteLog("LOGIN", LoginCtrl.UserName, "login.aspx", "Commerce Manager", "SYSTEM", String.Empty, true);
                if (url.Contains(".axd") || url.Contains("/Apps/Core/Controls/Uploader/")) // prevent redirecting to report files
                {
                    Response.Redirect("~/default.aspx");
                }
                else
                {
                    Response.Redirect(url);
                }
            }
            else
            {
                LogManager.WriteLog("LOGIN", LoginCtrl.UserName, "login.aspx", "Commerce Manager", "SYSTEM", "Login or password are incorrect.", false);
                LoginCtrl.FailureText = "Login failed. Please try again.";
            }
        }
Ejemplo n.º 2
0
 void PasswordCtrl_ChangedPassword(object sender, EventArgs e)
 {
     if (String.Compare(PasswordCtrl.UserName, ProfileContext.Current.UserName, StringComparison.OrdinalIgnoreCase) != 0)
     {
         // re-set authentication cookie
         if (Request.Cookies[FormsAuthentication.FormsCookieName] != null)
         {
             FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value);
             CHelper.CreateAuthenticationCookie(ticket.Name, Membership.Provider.ApplicationName, ticket.IsPersistent);
         }
     }
 }