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

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

            DisplayMessage("Thank You! Your request has been submitted. If the email address you entered is in our system you will receive an email shortly. If you do not receive an email after a while, please verify that you entered the registered email associated with your SHIP NPR account. Please check your Junk mail folder as well. If you have additional questions, please contact the SHIP NPR Help Desk at 1-800-253-7154, option 1.", false);

            EmailAddress = Email.Text.Trim();

            if (!RegisterUserBLL.DoesUserNameExist(EmailAddress))
            {
                DisplayMessage("Thank You! Your request has been submitted. If the email address you entered is in our system you will receive an email shortly. If you do not receive an email after a while, please verify that you entered the registered email associated with your SHIP NPR account. Please check your Junk mail folder as well. If you have additional questions, please contact the SHIP NPR Help Desk at 1-800-253-7154, option 1.", false);
                return;
            }
            else
            {
                //sammit: Check if the user exist and Is he trying to change the password in the sameday
                // if he is trying to do so Send an e-mail with the warning message
                int?UserId = UserBLL.GetUserIdForUserName(EmailAddress);
                if (UserId.HasValue)
                {
                    UserProfile userProf = UserBLL.GetUserProfile((int)UserId);
                    if (userProf.LastPasswordChangeDate != null && ((DateTime)userProf.LastPasswordChangeDate).Date == System.DateTime.Today)
                    {
                        //Send Email to User with warning.
                        if (SendPasswordCanNotBeChangedEmail())
                        {
                            DisplayMessage("Thank You! Your request has been submitted. If the email address you entered is in our system you will receive an email shortly. If you do not receive an email after a while, please verify that you entered the registered email associated with your SHIP NPR account. Please check your Junk mail folder as well. If you have additional questions, please contact the SHIP NPR Help Desk at 1-800-253-7154, option 1.", false);
                        }
                        else
                        {
                            DisplayMessage("Sorry. We were unable to send password reset instructions to your mail. Please contact help desk if the problem persists.", true);
                        }

                        return;
                    }
                }

                //Send Email to User for verification.
                if (SendPasswordResetEmail())
                {
                    DisplayMessage("Thank You! Your request has been submitted. If the email address you entered is in our system you will receive an email shortly. If you do not receive an email after a while, please verify that you entered the registered email associated with your SHIP NPR account. Please check your Junk mail folder as well. If you have additional questions, please contact the SHIP NPR Help Desk at 1-800-253-7154, option 1.", false);
                }
                else
                {
                    DisplayMessage("Sorry. We were unable to send password reset instructions to your mail. Please contact help desk if the problem persists.", true);
                }
            }
        }
Esempio n. 2
0
        protected void RegisterUserCommand(object sender, EventArgs e)
        {
            //if(valid)
            Page.Validate("RegisterForm");

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

            UserName = Email.Text.Trim();

            if (RegisterUserBLL.DoesUserNameExist(UserName))
            {
                DisplayMessage("The Primary Email address is already registered. Duplicates are not allowed.", true);
                return;
            }
            else
            {
                //TODO: Add transaction scope, email verification logic and appropriate error messages.
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    int?newUserId;
                    if (!UserBLL.CreateUser(CreateRegistrationObject(), null, false, this.AccountInfo.UserId, out newUserId))
                    {
                        DisplayMessage("Unable to add user. Please contact support if the issue persists.", true);
                        return;
                    }
                    else
                    {
                        if (!SendVerificationEmail(newUserId.Value))
                        {
                            return;
                        }
                        else
                        {
                            scope.Complete();
                            ShowSuccess();
                            ClearForm();
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        protected void ChangeEmailCommand(object sender, EventArgs e)
        {
            //TODO: Validation to be replaced with ProxyValidator
            Page.Validate("ChangeEmail");
            if (Page.IsValid)
            {
                //using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                //{
                bool   DoCommit = false;
                string ErrorMessage;
                string NewEmail = Email.Text.Trim();

                //Check if the Username already exists
                if (RegisterUserBLL.DoesUserNameExist(NewEmail))
                {
                    DisplayMessage("The Primary Email address is already registered. Duplicates are not allowed.", true);
                    return;
                }
                else
                {
                    if (UserBLL.ChangeEmail(ShiptalkPrincipal.UserId, ShiptalkPrincipal.Username, NewEmail, ShiptalkPrincipal.UserId, out ErrorMessage))
                    {
                        if (VerifyEmail.SendEmailVerificationNotificationforEmailChange(false, ShiptalkPrincipal.UserId, ShiptalkPrincipal.UserId, NewEmail, out ErrorMessage))
                        {
                            DoCommit = true;
                        }
                    }

                    if (DoCommit)
                    {
                        //scope.Complete();
                        DisplayMessage("Your request has been submitted. You will receive this Change Email request information email at your old Email address and  'Email verification' email at your new Email address shortly. Please follow the instruction to complete the Email verification process . If you do not receive an email after a while, please contact the help desk.", false);
                    }
                    else
                    {
                        DisplayMessage("Sorry. Unable to change your email. Please contact support for assistance.", false);
                    }
                    //}
                }
            }
        }
Esempio n. 4
0
        protected void dataSourceUserView_Updated(object sender, ObjectContainerDataSourceStatusEventArgs e)
        {
            if (UserViewData != null)
            {
                if (RegisterUserBLL.DoesUserNameExist(UserViewData.PrimaryEmail))
                {
                    DisplayMessage("The Primary Email address is already registered. Duplicates are not allowed.", true);
                    //formView.ChangeMode(FormViewMode.Edit);
                }
                else
                {
                    IRegisterUser regBLL = RegisterUserBLL.CreateRegistrationProviderObject(CreateRegistrationObject());
                    regBLL.ValidateData();
                    if (regBLL.IsValid)
                    {
                        if (regBLL.Save())
                        {
                            AddPresentorStatus = 1;
                            DisplayMessage("The Presenter has been added successfully. You may add another presenter or close this window.", false);
                            UserViewData = new UserViewData();
                        }
                        else
                        {
                            DisplayMessage("Unable to add presenter. Please contact support if the issue persists. Error: " + regBLL.ErrorMessage, true);
                        }
                    }
                    else
                    {
                        DisplayMessage("Validation error occured while adding new User. Error: " + regBLL.ErrorMessage, true);
                    }
                }
            }


            Page.DataBind();
        }
Esempio n. 5
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. 6
0
        protected void dataSourceUserView_Updated(object sender, ObjectContainerDataSourceStatusEventArgs e)
        {
            Page.Validate("UserProfile");
            if (!Page.IsValid)
            {
                return;
            }

            UserViewData ChangedUserData = (UserViewData)e.Instance;

            try
            {
                if (IsCMSOrStateScope)
                {
                    UserBLL.UpdateIsAdminStatus(ChangedUserData.UserId, ChangedUserData.IsAdmin);
                }
            }
            catch (Exception UpdateAccountEx)
            {
                DisplayMessage("Failed while saving administrator status. Please try later or contact support for assistance.", true);
                return;
            }

            //Update IsActive of UserData with what we got from Updating method.
            //ChangedUserData.IsActive = IsActiveUser;
            //using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
            //{
            if (UserBLL.UpdateUserProfile(CreateUserProfile(ChangedUserData), this.AccountInfo.UserId))
            {
                if (!UserData.IsShipDirector && UserData.IsUserStateScope)
                {
                    string ErrorMessage;
                    if (!UserBLL.SaveDescriptors(ChangedUserData.UserId, GetDescriptorsSelectedByAdmin(), ShiptalkLogic.Constants.Defaults.DefaultValues.AgencyIdForNonAgencyUsers, this.AccountInfo.UserId, out ErrorMessage))
                    {
                        DisplayMessage(ErrorMessage, true);
                        return;
                    }

                    if (!UserBLL.UpdateStateSuperDataEditor(ChangedUserData.UserId, ChangedUserData.IsStateSuperDataEditor, this.AccountInfo.UserId))
                    {
                        DisplayMessage("An error occured while updating the super data editor status", true);
                        return;
                    }
                }

                //Update the Is Approver Designate status for CMS/State scope Admins alone.
                //Ignore Ship directors and CMS Admins.
                if (UserData.IsAdmin)
                {
                    if ((!UserData.IsCMSAdmin && UserData.IsUserCMSScope) || (!UserData.IsShipDirector && UserData.IsUserStateScope))
                    {
                        if (!UserBLL.UpdateApproverDesignate(UserData.UserId, GetApproverDesignateSelection(), this.AccountInfo.UserId))
                        {
                            DisplayMessage("Failed while updating approver designate status. Please try later or contact support for assistance.", true);
                            return;
                        }
                    }
                }

                bool ReviewerUpdateFailed = false;
                if (ScopeIdOfUser == Scope.State.EnumValue <int>())
                {
                    if (NewSupervisorId == -1)
                    {
                        NewSupervisorId = 0;
                    }

                    if (NewSupervisorId != UserIdOfOldReviewer)
                    {
                        //Save the new ReviewerID as Supervisor
                        if (!UserBLL.SaveSupervisorForUser(ChangedUserData.UserId, NewSupervisorId, null, this.AccountInfo.UserId))
                        {
                            //If update failed, then
                            ReviewerUpdateFailed = true;
                        }
                    }
                }
                //Lavnaya: Included Change Email process : 09/02/2012
                //If Primary Email is changed, then the email should be sent to user's old email id and as well as to new email id to notify them.
                // Email verification link will be sen to the user's new email id. Users can login using their old email id till they vefy the new email. this process is same as "Edit my Email" functionality.
                //If the Primary EMail id is not changed, then we dont change it in database.

                bool   DoCommit = false;
                string ErrorMsg;
                string NewEmail = string.Empty;

                TextBox Email = formView.FindControl("Email") as TextBox;

                NewEmail = Email.Text;

                if (NewEmail != UserData.PrimaryEmail)
                {
                    if (NewEmail != "" && NewEmail != null)
                    {
                        //Check if the Username already exists
                        if (RegisterUserBLL.DoesUserNameExist(NewEmail))
                        {
                            DisplayMessage("The Primary Email address is already registered. Duplicates are not allowed.", true);
                            return;
                        }
                        else
                        {
                            if (UserBLL.ChangeEmail(ChangedUserData.UserId, UserData.PrimaryEmail, NewEmail, this.AccountInfo.UserId, out ErrorMsg))
                            {
                                if (VerifyEmail.SendEmailVerificationNotificationforEmailChange(false, ChangedUserData.UserId, ChangedUserData.UserId, NewEmail, out ErrorMsg))
                                {
                                    DoCommit = true;
                                }
                            }

                            //if (DoCommit)
                            //{
                            //    //scope.Complete();
                            //    DisplayMessage("Your request has been submitted. You will receive this Change Email request information email at your old Email address and  'Email verification' email at your new Email address shortly. Please follow the instruction to complete the Email verification process . If you do not receive an email after a while, please contact the help desk.", false);
                            //}

                            //}
                        }
                    }
                }


                //Lavnaya: Included Change Email process : 09/02/2012 -- End

                if (ReviewerUpdateFailed)
                {
                    DisplayMessage("Unable to save new supervisor. Please try later or contact support for assistance.", true);
                }


                //else if (!DoCommit)Pbattineni: If (!DoCommit) & and New email is not equal to Primary email then Throw error Message- 10/08/12
                else if (!DoCommit && NewEmail != UserData.PrimaryEmail)
                {
                    DisplayMessage("Sorry. Unable to change your email. Please contact support for assistance.", true);
                }
                else
                {
                    //scope.Complete();
                    DisplayMessage("The submitted information has been saved successfully.", false);
                }
                //formView.DataBind();
                //listViewUserRegionalProfiles.DataBind();
                //Page.DataBind();
            }
            else
            {
                DisplayMessage("Sorry. We were unable to save the information. Please contact support for assistance.", true);
            }
            //}

            //Get Fresh data for rebind.
            FetchUserData();
        }
Esempio n. 7
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);
                }
            }
        }