Exemplo 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;
            }
        }
Exemplo n.º 2
0
        public static UserInfo GetUserByCode(CompleteRec model, string code, bool isTest = false)
        {
            UserInfo user = null;

            try
            {
                ISprocCalls      sprocCalls      = AppTools.InitSprocCalls(isTest);
                IMembershipTools membershipTools = AppTools.InitMembershipTools(isTest);
                user = sprocCalls.UserInfoGetByCode(code);

                if (user.Email == model.Email)
                {
                    if (membershipTools.UpdatePassword(model.UserName, model.Password))
                    {
                        string errorMessage = string.Empty;
                        user.GroupUsers  = GetGroupsByUserName(user.UserName, sprocCalls);
                        user.RecoverCode = null;
                        UpdateUser(user, out errorMessage, isTest);

                        if (string.IsNullOrEmpty(errorMessage) == false)
                        {
                            throw new Exception(errorMessage);
                        }
                    }
                }
                else
                {
                    throw new Exception("User recovered email does not match.");
                }

                return(user);
            }
            catch (Exception ex)
            {
                DBCommands.RecordError(ex);
            }

            return(user);
        }