Esempio n. 1
0
        public static void UpdatePassword(UpdateAccount model, out string errorMessage, bool isTest = false)
        {
            try
            {
                IMembershipTools membershipTools = AppTools.InitMembershipTools(isTest);
                errorMessage = string.Empty;

                if (model.NewPassword.Length < 9)
                {
                    errorMessage = "Password must be at least 9 characters and have a special character";
                }
                else if (model.CurrentPassword == model.NewPassword)
                {
                    errorMessage = "New password must be different from the current password.";
                }
                else if (model.NewPassword != model.RepeatPassword)
                {
                    errorMessage = "New password and repeated password does not match.";
                }
                else if (membershipTools.UpdatePassword(model.UserName, model.NewPassword) == false)
                {
                    errorMessage = "Error updating account.";
                }
            }
            catch (Exception ex)
            {
                DBCommands.RecordError(ex);
                errorMessage = ex.Message;
            }
        }
Esempio n. 2
0
        public static void RecoverPassword(RecoverModel model, out string errorMessage, bool isTest = false)
        {
            try
            {
                IMembershipTools membershipTools = AppTools.InitMembershipTools(isTest);
                IEmailTools      emailTools      = AppTools.InitEmailTools(isTest);
                errorMessage = string.Empty;

                if (model.Email == membershipTools.GetUserEmail(model.UserName))
                {
                    string tempPassword = Membership.GeneratePassword(9, 1);
                    if (membershipTools.SetTempPassword(model.UserName, tempPassword) == false)
                    {
                        errorMessage = "Error updating account";
                    }

                    string emailBody = BuildRecoverBody(model.UserName, tempPassword);
                    if (emailTools.SendEmail(emailBody, model.Email) == false)
                    {
                        errorMessage = "Error sending recover email.";
                    }
                }
                else
                {
                    errorMessage = "Email and username is not valid.";
                }
            }
            catch (Exception ex)
            {
                DBCommands.RecordError(ex);
                errorMessage = ex.Message;
            }
        }
Esempio n. 3
0
        public static void UpdateUser(UserInfo user, out string errorMessage, bool isTest = false)
        {
            try
            {
                errorMessage = ValidateUser(user);

                if (string.IsNullOrEmpty(errorMessage))
                {
                    IMembershipTools membershipTools = AppTools.InitMembershipTools(isTest);
                    ISprocCalls      sprocCalls      = AppTools.InitSprocCalls(isTest);

                    if (membershipTools.UpdateUserEmail(user.UserName, user.Email) == false)
                    {
                        errorMessage = "Error updating email.";
                    }

                    if (sprocCalls.UserInfoUpdate(user) == false)
                    {
                        errorMessage = "Error saving user information";
                    }
                }
            }
            catch (Exception ex)
            {
                DBCommands.RecordError(ex);
                errorMessage = ex.Message;
            }
        }
Esempio n. 4
0
 public static bool DeleteUser(string userName, bool isTest = false)
 {
     try
     {
         IMembershipTools membershipTools = AppTools.InitMembershipTools(isTest);
         return(membershipTools.DeleteUser(userName));
     }
     catch (Exception ex)
     {
         DBCommands.RecordError(ex);
         return(false);
     }
 }