Esempio n. 1
0
        protected void AddUserCommand(object sender, EventArgs e)
        {
            //if(valid)
            Page.Validate("RegisterForm");

            bool FormIsValid = IsFormValid();

            //For some reason, CaptchaText EnableViewState=false isn't working. So doing this...
            //CaptchaText.Text = string.Empty;

            if (!FormIsValid)
            {
                DisplayMessage("Please fix the error(s) displayed in red and submit again", true);
                return;
            }

            //sammit-start
            if (PasswordValidation.DoesTextContainsWord(Password.Text.Trim().ToLower()))
            {
                DisplayMessage("The entered password contains a dictionary word and is not allowed.", true);
                return;
            }

            if (PasswordValidation.DoesTextContainsFirstLastName(Password.Text.Trim().ToLower(), FirstName.Text.Trim().ToLower(), LastName.Text.Trim().ToLower(), MiddleName.Text.Trim().ToLower()))
            {
                DisplayMessage("The entered password contains either FirstName/MiddleName/LastName and is not allowed.", true);
                return;
            }

            if (PasswordValidation.DoesPassWordContainsEmail(Email.Text.Trim().ToLower(), Password.Text.Trim().ToLower()))
            {
                DisplayMessage("The entered password contains your email-id and is not allowed.", true);
                return;
            }

            if (PasswordValidation.DoesContainFourConsecutive(Password.Text.Trim().ToLower()))
            {
                DisplayMessage("The entered password contains 4 consecutive letter/number and is not allowed.", true);
                return;
            }
            //sammit-end

            UserName = Email.Text.Trim();

            if (RegisterUserBLL.DoesUserNameExist(UserName))
            {
                DisplayMessage("The Primary Email address is already registered. Duplicates are not allowed.", true);
                return;
            }
            else
            {
                //if (!UserBLL.CreateUser(CreateRegistrationObject(), false, this.AccountInfo.UserId, out newUserId))
                IRegisterUser regBLL = RegisterUserBLL.CreateRegistrationProviderObject(CreateRegistrationObject());
                regBLL.ValidateData();
                if (regBLL.IsValid)
                {
                    if (regBLL.Save())
                    {
                        ShowSuccess();
                        ClearForm();
                    }
                    else
                    {
                        DisplayMessage("Unable to add user. Please contact support if the issue persists. Error: " + regBLL.ErrorMessage, true);
                        return;
                    }
                }
                else
                {
                    DisplayMessage("Validation error occured while adding new User. Error: " + regBLL.ErrorMessage, true);
                }
            }
        }
Esempio n. 2
0
        protected void RegisterUserCommand(object sender, EventArgs e)
        {
            //if(valid)
            Page.Validate("RegisterForm");

            bool FormIsValid = IsFormValid();

            //For some reason, CaptchaText EnableViewState=false isn't working. So doing this...
            CaptchaText.Text = string.Empty;

            if (!FormIsValid)
            {
                DisplayMessage("Please fix the error(s) displayed in red and submit again", true);
                return;
            }

            //sammit-start
            if (PasswordValidation.DoesTextContainsWord(Password.Text.Trim().ToLower()))
            {
                DisplayMessage("The entered password contains a dictionary word and is not allowed.", true);
                return;
            }

            if (PasswordValidation.DoesTextContainsFirstLastName(Password.Text.Trim().ToLower(), FirstName.Text.Trim().ToLower(), LastName.Text.Trim().ToLower(), MiddleName.Text.Trim().ToLower()))
            {
                DisplayMessage("The entered password contains either FirstName/MiddleName/LastName and is not allowed.", true);
                return;
            }

            if (PasswordValidation.DoesPassWordContainsEmail(Email.Text.Trim().ToLower(), Password.Text.Trim().ToLower()))
            {
                DisplayMessage("The entered password contains your email-id and is not allowed.", true);
                return;
            }

            if (PasswordValidation.DoesContainFourConsecutive(Password.Text.Trim().ToLower()))
            {
                DisplayMessage("The entered password contains 4 consecutive letter/number and is not allowed.", true);
                return;
            }
            //sammit-end

            string UserName = Email.Text.Trim();

            if (RegisterUserBLL.DoesUserNameExist(UserName))
            {
                DisplayMessage("The Primary Email address is already registered. Duplicates are not allowed.", true);
                return;
            }
            else
            {
                //If Role selected is SHIP Admin, Check if a Ship Director already exists for the Chosen state
                if (_selectedRole.IsStateAdmin && chBoxIsShipDirector.Checked)
                {
                    if (LookupBLL.GetShipDirectorForState(ddlStates.SelectedValue.Trim()).HasValue)
                    {
                        DisplayMessage(string.Format("A SHIP Director already exists for state of {0}", State.GetStateName(StateFIPSSelected)), true);
                        return;
                    }
                }

                //Fill personal profile info here...
                RegistrationObject regObj = new RegistrationObject();
                regObj.FirstName      = FirstName.Text.Trim();
                regObj.MiddleName     = MiddleName.Text.Trim();
                regObj.LastName       = LastName.Text.Trim();
                regObj.NickName       = NickName.Text.Trim();
                regObj.Suffix         = Suffix.Text.Trim();
                regObj.Honorifics     = Honorifics.Text.Trim();
                regObj.SecondaryEmail = SecondaryEmail.Text.Trim();
                regObj.PrimaryPhone   = PrimaryPhone.Text.Trim();
                regObj.SecondaryPhone = SecondaryPhone.Text.Trim();

                //Fill login info and Role
                regObj.PrimaryEmail  = UserName;
                regObj.ClearPassword = Password.Text.Trim(); //sammit
                regObj.Password      = Password.Text.Trim();
                regObj.RoleRequested = _selectedRole;

                regObj.OldShipUserId         = OldShipUserId;
                regObj.IsRegistrationRequest = true;

                //GetStateFIPS (including CMS User)
                regObj.StateFIPS = GetStateFIPSForNewUser();

                //Get regional IDs (AgencyID, Sub State Regional ID etc)
                switch (regObj.RoleRequested.scope)
                {
                case Scope.CMSRegional:
                    regObj.UserRegionalAccessProfile.RegionId = int.Parse(ddlCMSRegion.SelectedValue.Trim());
                    break;

                case Scope.SubStateRegion:
                    regObj.UserRegionalAccessProfile.RegionId = int.Parse(ddlSubStateRegion.SelectedValue.Trim());
                    break;

                case Scope.Agency:
                    regObj.UserRegionalAccessProfile.RegionId = int.Parse(ddlAgency.SelectedValue.Trim());
                    break;

                case Scope.State:
                    regObj.IsShipDirector = chBoxIsShipDirector.Checked;
                    break;
                }

                //Populate User Descriptors for the Regions other than Agencies
                PopulateUserDescriptors(ref regObj);


                //Register
                IRegisterUser regBLL = RegisterUserBLL.CreateRegistrationProviderObject(regObj);
                regBLL.ValidateData();
                if (regBLL.IsValid)
                {
                    if (!regBLL.Save())
                    {
                        DisplayMessage("Unable to complete registration. " + regBLL.ErrorMessage, true);
                    }
                    else
                    {
                        ShowSuccess();
                        ClearForm();
                    }
                }
                else
                {
                    DisplayMessage("Error. Validation error occured during registration. " + regBLL.ErrorMessage, true);
                }
            }
        }
Esempio n. 3
0
        protected void ChangePasswordCommand(object sender, EventArgs e)
        {
            //TODO: Validation to be replaced with ProxyValidator
            Page.Validate("ChangePasswordGroup");
            if (Page.IsValid)
            {
                //IMPORTANT! IMPORTANT! IMPORTANT!
                //NOTE: NO MATTER POSTBACK OR NOT, WE MUST VALIDATE THE TOKEN, EMAIL - FOR SECURITY REASONS.
                //OTHERWISE MANIPULATED OR ARTIFICIALLY CREATED POSTBACKS CAN HELP RESET PASSWORD.
                if (!UserBLL.IsPasswordResetTokenValid(Token, UserName))
                {
                    DisplayMessage("Sorry,", "An error occured. Your action was not recognized. Please contact support center if you need further assistance.");
                }

                string ErrorMessage;
                int?   UserId = UserBLL.GetUserIdForUserName(UserName);
                if (UserId.HasValue)
                {
                    //sammit-start
                    if (PasswordValidation.DoesTextContainsWord(Password.Text.Trim().ToLower()))
                    {
                        DisplayMessage("The entered password contains a dictionary word and is not allowed.", true);
                        return;
                    }

                    UserProfile userProf = UserBLL.GetUserProfile((int)UserId);
                    UserAccount userAcc  = UserBLL.GetUserAccount((int)UserId);

                    if (PasswordValidation.DoesTextContainsFirstLastName(Password.Text.Trim().ToLower(), userProf.FirstName.Trim().ToLower(), userProf.LastName.Trim().ToLower(), userProf.MiddleName.Trim().ToLower()))
                    {
                        DisplayMessage("The entered password contains either FirstName/MiddleName/LastName and is not allowed.", true);
                        return;
                    }

                    if (PasswordValidation.DoesPassWordContainsEmail(userAcc.PrimaryEmail.Trim().ToLower(), Password.Text.Trim().ToLower()))
                    {
                        DisplayMessage("The entered password contains your email-id and is not allowed.", true);
                        return;
                    }

                    if (PasswordValidation.DoesContainFourConsecutive(Password.Text.Trim().ToLower()))
                    {
                        DisplayMessage("The entered password contains 4 consecutive letter/number and is not allowed.", true);
                        return;
                    }
                    //sammit-end

                    //using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                    //{
                    if (UserBLL.ChangePassword(UserId.Value, Password.Text.Trim(), out ErrorMessage))
                    {
                        if (!SendEmailToUserAboutPasswordChange())
                        {
                            DisplayMessage("Sorry. We were unable to complete the password change because we were unable to send confirmation email to your email address on record. If the problem persists, please contact support.", true);
                            return;
                        }

                        //DisplayMessage("Your password has been changed successfully. You may login with your new password any time.", false);
                        DisplayMessage("Success!", "Your password has been successfully changed.  You may login any time using the new password. <br> <br><a href='https://shipnpr.shiptalk.org/default.aspx'> Click here to login </a> ");
                        PasswordChangePanel.Visible = false;
                        //scope.Complete();
                    }
                    else

                    {
                        // DisplayMessage("Sorry. Unable to change password. Please contact support for assistance.", false);

                        //sammit show the error message
                        DisplayMessage(ErrorMessage, true);
                        return;
                    }
                    //}
                }
                else
                {
                    DisplayMessage("Sorry. Unable to change password. Please contact support for assistance.", false);
                }
            }
        }
Esempio n. 4
0
        protected void ChangePasswordCommand(object sender, EventArgs e)

        {
            //TODO: Validation to be replaced with ProxyValidator
            Page.Validate("ChangePasswordGroup");
            if (Page.IsValid)
            {
                //sammit-start

                UserProfile userProf = UserBLL.GetUserProfile(ShiptalkPrincipal.UserId);
                if (userProf.LastPasswordChangeDate != null && ((DateTime)userProf.LastPasswordChangeDate).Date == System.DateTime.Today)
                {
                    DisplayMessage("You are not allowed to change your password more than once in a day.", true);
                    return;
                }


                if (PasswordValidation.DoesTextContainsWord(Password.Text.Trim().ToLower()))
                {
                    DisplayMessage("The entered password contains a dictionary word and is not allowed.", true);
                    return;
                }


                UserAccount userAcc = UserBLL.GetUserAccount(ShiptalkPrincipal.UserId);
                EmailAddress = userAcc.PrimaryEmail;

                if (PasswordValidation.DoesTextContainsFirstLastName(Password.Text.Trim().ToLower(), userProf.FirstName.Trim().ToLower(), userProf.LastName.Trim().ToLower(), userProf.MiddleName.Trim().ToLower()))
                {
                    DisplayMessage("The entered password contains either FirstName/MiddleName/LastName and is not allowed.", true);
                    return;
                }

                if (PasswordValidation.DoesPassWordContainsEmail(userAcc.PrimaryEmail.Trim().ToLower(), Password.Text.Trim().ToLower()))
                {
                    DisplayMessage("The entered password contains your email-id and is not allowed.", true);
                    return;
                }

                if (PasswordValidation.DoesContainFourConsecutive(Password.Text.Trim().ToLower()))
                {
                    DisplayMessage("The entered password contains 4 consecutive letter/number and is not allowed.", true);
                    return;
                }
                //sammit-end

                //using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                //{
                bool   DoCommit = false;
                string ErrorMessage;
                if (UserBLL.ChangePassword(ShiptalkPrincipal.UserId, Password.Text.Trim(), out ErrorMessage))
                {
                    if (SendEmailToUserAboutPasswordChange())
                    {
                        DoCommit = true;
                    }
                }
                else
                {
                    //sammit show the error message
                    DisplayMessage(ErrorMessage, true);
                    return;
                }

                if (DoCommit)
                {
                    //scope.Complete();
                    DisplayMessage("Success!", "Your password has been changed successfully.");
                    ChangePasswordPanel.Visible = false;
                }
                else
                {
                    DisplayMessage("Sorry. Unable to change your password. Please contact support for assistance.", false);
                }
                //}
            }
        }