public void ChangePassword_Click(object sender, EventArgs e)
 {
     using (LoginService service = new LoginService())
     {
         try
         {
             if (!NewPassword.Text.Equals(ConfirmNewPassword.Text) || NewPassword.Text.Equals(string.Empty))
             {
                 ErrorMessage.Text         = ErrorMessages.PasswordsDontMatch;
                 ErrorMessagePanel.Visible = true;
             }
             else
             {
                 service.ChangePassword(Username.Text, OriginalPassword.Value, NewPassword.Text);
                 SessionManager.InitializeSession(Username.Text, NewPassword.Text);
             }
         }
         catch (Exception ex)
         {
             ErrorMessage.Text         = ex.Message;
             ErrorMessagePanel.Visible = true;
             NewPassword.Focus();
             // May want to elimiate this.
             Platform.Log(LogLevel.Error, ex, "Unexpected exception changing password: {0}.", ex.Message);
         }
     }
 }
Пример #2
0
        public virtual ActionResult ForgotPassword(ForgotPasswordViewModel forgotPasswordViewModel)
        {
            var model = _forgotPasswordViewModelBuilder.Build(forgotPasswordViewModel.ForgotPasswordForm);

            if (_loginService.IsValidForgotPasswordForm(_modelState, model.ForgotPasswordForm))
            {
                var user = _loginService.GetUser(model.ForgotPasswordForm.Email?.ToLower());
                if (user == null)
                {
                    model.ErrorMessage = "login.usernotfound".AsWebSiteString();
                }
                else
                {
                    if (!string.IsNullOrEmpty(user.Email))
                    {
                        if (_loginService.ChangePassword(user, false, true, model.ChannelSystemId, _securityToken))
                        {
                            model.Message = "login.passwordsent".AsWebSiteString();
                        }
                        else
                        {
                            model.ErrorMessage = "login.passwordcouldnotbesent".AsWebSiteString();
                        }
                    }
                    else
                    {
                        model.ErrorMessage = "login.passwordcouldnotbesent".AsWebSiteString();
                    }
                }
            }

            return(View(model));
        }
        protected void btnChangePassword_Click(object sender, EventArgs e)
        {
            objComLogin = new ComLogin();
            int i = 0;

            if (txtOldPassword.Text == Session["password"].ToString())
            {
                if (txtNewPassword.Text == txtConfirmNewPassword.Text)
                {
                    objComLogin.NewPassword       = txtNewPassword.Text;
                    objComLogin.UserId            = Session["user_id"].ToInt32();
                    objWebService                 = new LoginService();
                    objWebService.AuthSoapHdValue = ServiceAuth.ServiceAuthenticationLogin();
                    i = objWebService.ChangePassword(objComLogin);
                    if (i > 0)
                    {
                        Session["password"] = txtNewPassword.Text;
                        Response.Write("<script>alert('पासवर्ड परिवर्तन सफल भएको छ।')</script>");
                        Response.Redirect(Constants.ConstantAppPath + "/Home.aspx");
                    }
                }
                else
                {
                    Response.Write(
                        "<script>alert('नयाँ पासवर्ड मिलेन।')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('पुरानो पासवर्ड मिलेन।')</script>");
            }
        }
Пример #4
0
 private async void ChangePassword(object obj)
 {
     ToggleProgressBarVisibility();
     if (await LoginService.ChangePassword(FireBaseUser))
     {
         OpenEventSelectorWindow();
     }
     ToggleProgressBarVisibility();
 }
Пример #5
0
        public override bool ChangePassword(string username, string oldPassword, string newPassword)
        {
            LoginService lgnSrv = new LoginService();

            lgnSrv.UserVM = (UserViewModel)HttpContext.Current.Session["UserVM"];
            string newPasshash = Crypto.HashPassword(newPassword);

            return(lgnSrv.ChangePassword(username, newPasshash));
        }
Пример #6
0
        public ActionResult SendForgortPassword(string emailAndUserId)
        {
            if (string.IsNullOrEmpty(emailAndUserId))
            {
                return(Json(UserPreValidationEnum.ChangePasswordFailed.ToString()));
                // return View("../Account/ForgotPassWizard", new LoginModel());
            }
            LoginService loginsrv = new LoginService();

            string[]         emailAndIDs = emailAndUserId.Split('~');
            string           emailOnly   = emailAndIDs[0];
            List <ComboBase> custDetails = loginsrv.GetAllCustomersByUserEmail(emailOnly);

            if (custDetails.Count > 0 && custDetails != null)
            {
                if (custDetails.Count() > 1 && emailAndIDs.Count() == 1)
                {
                    return(Json(custDetails));
                }
                else
                {
                    string password = string.Empty;
                    if (emailAndIDs.Count() == 1)
                    {
                        password = custDetails.FirstOrDefault().ItemID + DateTime.Now.Minute + DateTime.Now.Second;
                    }
                    else
                    {
                        password = emailAndIDs[1] + DateTime.Now.Minute + DateTime.Now.Second;
                    }
                    string encryptedPassword = Crypto.HashPassword(password);
                    bool   isPassUpdated     = loginsrv.ChangePassword(emailAndUserId, encryptedPassword);
                    if (isPassUpdated)
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.AppendLine("<p>Dear User,</p>");
                        sb.AppendLine("<p>We have processed your request for issuance of a password.</p>");
                        sb.AppendLine("<p>Your Email Id: " + emailOnly + "</p>");
                        sb.Append("<p>Your password is: " + password + "</p>");
                        sb.Append(". </p>");
                        sb.AppendLine();
                        EmailService mail = new EmailService();
                        mail.SendMail("Forgot Password", sb.ToString(), true, false, null, null, null, emailOnly, "FP");
                        return(Json(UserPreValidationEnum.ValidUser.ToString()));
                    }
                }
            }
            return(Json(UserPreValidationEnum.ChangePasswordFailed.ToString()));
        }
Пример #7
0
        public ActionResult UserPreValidations(string emailAndCustAutoID, string pass, string type = "")
        {
            if (HttpContext.Session["userVM"] != null)
            {
                HttpContext.Session.Remove("userVM");
            }
            WebSecurity.Logout();

            LoginService loginsrv = new LoginService();

            if (Request.IsAjaxRequest())
            {
                string[]         emailAndIDs = emailAndCustAutoID.Split('~');
                List <ComboBase> custDetails = loginsrv.GetAllCustomersByUserEmail(emailAndIDs[0]);
                if (custDetails.Count == 0 || custDetails == null)
                {
                    return(Json(UserPreValidationEnum.InvalidUserName.ToString()));
                }
                if (custDetails.Count > 1 && emailAndIDs.Count() == 1)
                {
                    return(Json(custDetails));
                }
                string hashedPassword   = loginsrv.ValidateUser(emailAndCustAutoID);
                bool   isDafultPassword = pass == ConfigurationManager.AppSettings["DefaultPassword"] ? true : false; //Crypto.VerifyHashedPassword(key, Resources.TCPResources.DafultPasswordText);
                if (!string.IsNullOrEmpty(pass))
                {
                    bool isValidUser = !string.IsNullOrEmpty(hashedPassword) && Crypto.VerifyHashedPassword(hashedPassword, pass);
                    if (isValidUser)
                    {
                        if (isDafultPassword)
                        {
                            string emailID = emailAndCustAutoID.Split('~')[0];
                            return(View("../Account/Manage", new LoginModel()
                            {
                                UserEmail = emailID, IsManageAccount = true, OldPassword = pass
                            }));
                        }
                        else
                        {
                            return(Json(UserPreValidationEnum.ValidUser.ToString()));
                        }
                    }
                    else
                    {
                        //Update Password logic
                        if (!string.IsNullOrEmpty(hashedPassword) && Crypto.VerifyHashedPassword(hashedPassword, ConfigurationManager.AppSettings["DefaultPassword"]) && string.IsNullOrEmpty(type))
                        {
                            loginsrv.ChangePassword(emailAndCustAutoID, Crypto.HashPassword(pass));
                            return(Json(UserPreValidationEnum.ValidUser.ToString()));
                        }
                        else
                        {
                            if (loginsrv.PersonIDExists(emailAndCustAutoID))
                            {
                                return(Json(UserPreValidationEnum.ChangePasswordFailed.ToString()));
                            }
                            else
                            {
                                return(Json(UserPreValidationEnum.InvalidUserName.ToString()));
                            }
                        }
                    }
                }
                return(Json(UserPreValidationEnum.ChangePasswordFailed.ToString()));
            }
            else
            {
                string   hashedPassword   = loginsrv.ValidateUser(emailAndCustAutoID);
                bool     isDafultPassword = pass == ConfigurationManager.AppSettings["DefaultPassword"] ? true : false; //Crypto.VerifyHashedPassword(key, Resources.TCPResources.DafultPasswordText);
                bool     isValidUser      = !string.IsNullOrEmpty(pass) && !string.IsNullOrEmpty(hashedPassword) && Crypto.VerifyHashedPassword(hashedPassword, pass);
                string[] email            = emailAndCustAutoID.Split('~');
                string   emailID          = email[0];
                string   custAutoID       = emailAndCustAutoID.Count() > 1 ? email[1] : string.Empty;
                if (isValidUser)
                {
                    if (isDafultPassword)
                    {
                        List <ComboBase> custDetails = loginsrv.GetAllCustomersByUserEmail(emailAndCustAutoID);
                        if (custDetails.Count > 1)
                        {
                            ViewBag.lstUserList = custDetails;
                            return(View("../TCPViews/Partial/ChangeLoginPassword", new LoginModel()
                            {
                                UserEmail = emailID, OldPassword = pass, CustAutoID = custAutoID
                            }));
                            //return RedirectToAction("GetSelectedCollectionItem", "ItemContainerPartial", new { groupID = (int)GroupEnum.EntirePenworthyCollection, currentPageIndex = 1, noofItemsPerPage = "60", quoteID = 0 });
                        }
                        return(View("../TCPViews/Partial/ChangeLoginPassword", new LoginModel()
                        {
                            UserEmail = emailID, IsManageAccount = true, OldPassword = pass, CustAutoID = custAutoID
                        }));
                    }
                    else
                    {
                        return(RedirectToAction("GetSelectedCollectionItem", "ItemContainerPartial", new { groupID = (int)GroupEnum.EntirePenworthyCollection, currentPageIndex = 1, noofItemsPerPage = "60", quoteID = 0 }));
                    }
                }
                return(RedirectToAction("GetSelectedCollectionItem", "ItemContainerPartial", new { groupID = (int)GroupEnum.EntirePenworthyCollection, currentPageIndex = 1, noofItemsPerPage = "60", quoteID = 0 }));
            }
        }
Пример #8
0
        public void ChangePassword_Click(object sender, EventArgs e)
        {
            using (LoginService service = new LoginService())
            {
                try
                {
                    SessionInfo session = service.Login(ChangePasswordUsername.Text, OriginalPassword.Text, ImageServerConstants.DefaultApplicationName);

                    if (!NewPassword.Text.Equals(ConfirmNewPassword.Text) || NewPassword.Text.Equals(string.Empty))
                    {
                        ErrorMessage.Text         = ErrorMessages.PasswordsDoNotMatch;
                        ErrorMessagePanel.Visible = true;
                    }
                    else
                    {
                        service.ChangePassword(ChangePasswordUsername.Text, OriginalPassword.Text, NewPassword.Text);

                        session = service.Login(ChangePasswordUsername.Text, NewPassword.Text, ImageServerConstants.DefaultApplicationName);
                        SessionManager.InitializeSession(session);

                        if (LoginPasswordChange.Checked)
                        {
                            Response.Redirect(
                                FormsAuthentication.GetRedirectUrl(ChangePasswordUsername.Text, false), false);
                        }
                        else
                        {
                            ModalDialog1.Hide();
                        }
                    }
                }
                catch (ArgumentException ex)
                {
                    Platform.Log(LogLevel.Error, ex, "Unable to change password for {0}: {1}", ChangePasswordUsername.Text, ex.Message);
                    string error = String.Format(ErrorMessages.ChangePasswordError, ex.Message);
                    ShowError(error);
                }
                catch (PasswordExpiredException ex)
                {
                    Platform.Log(LogLevel.Error, ex, "Unable to change password for {0}: {1}", ChangePasswordUsername.Text, ex.Message);
                    ShowError(ErrorMessages.PasswordExpired);
                }
                catch (UserAccessDeniedException ex)
                {
                    Platform.Log(LogLevel.Error, ex, "Unable to change password for {0}: {1}", ChangePasswordUsername.Text, ex.Message);
                    ShowError(ErrorMessages.UserAccessDenied);
                }
                catch (RequestValidationException ex)
                {
                    // NOTE: The server is throwing FaultException<RequestValidationException> when username or password doesn't match the configured policy
                    Platform.Log(LogLevel.Error, ex, "Unable to change password for {0}: {1}", ChangePasswordUsername.Text, ex.Message);

                    string error = String.Format(ErrorMessages.PasswordPolicyNotMet);
                    ShowError(error);
                }
                catch (CommunicationException ex)
                {
                    Platform.Log(LogLevel.Error, ex, ErrorMessages.CannotContactEnterpriseServer);
                    ShowError(ErrorMessages.CannotContactEnterpriseServer);
                }
                catch (Exception ex)
                {
                    ShowError(ex.Message);
                    // May want to elimiate this.
                    Platform.Log(LogLevel.Error, ex, "Unexpected exception changing password: {0}.", ex.Message);
                }
            }
        }
        public ActionResult <IEnumerable <string> > ChangePassword([FromBody] IntermediateLogin intermediateLogin)
        {
            ILoginService service = new LoginService();

            return(Ok(service.ChangePassword(intermediateLogin.Login, intermediateLogin.NewPassword)));
        }