public JsonResult UpdateSecurityQuestion(SecurityQuestionModel model, string password)
        {
            string sErrorMsg = null;
            bool   bSuccess  = false;

            try {
                StringActionResult sar = this.serviceClient.Instance.UserUpdateSecurityQuestion(
                    this.context.User.Name,
                    UiCustomerOrigin.Get().GetOrigin(),
                    new DasKennwort(password),
                    model.Question,
                    model.Answer
                    );

                sErrorMsg = sar.Value;

                bSuccess = string.IsNullOrWhiteSpace(sErrorMsg);
            } catch (Exception e) {
                ms_oLog.Alert(e, "Failed to update security question for customer '{0}'.", this.context.User.Name);
                sErrorMsg = "Failed to update security question.";
                bSuccess  = false;
            }             // try

            return(Json(new { success = bSuccess, error = sErrorMsg, }));
        }         // UpdateSecurityQuestion
Пример #2
0
        public JsonResult ChangeEmail(int id, string email)
        {
            string sErrorMessage;

            try {
                StringActionResult sar = m_oServiceClient.Instance.UserChangeEmail(m_oContext.UserId, id, email);
                sErrorMessage = sar.Value;
            }
            catch (Exception e) {
                sErrorMessage = "Failed to change a user email.";
                ms_oLog.Alert(e, sErrorMessage);
            }             // try

            return(Json(new { success = string.IsNullOrWhiteSpace(sErrorMessage), error = sErrorMessage, }));
        }         // ChangeEmail
Пример #3
0
        public JsonResult Update(string name, string password)
        {
            try {
                StringActionResult ar = m_oServiceClient.Instance.ValidateAndUpdateLinkedHmrcPassword(
                    new Encrypted(_context.Customer.Id.ToString()),
                    new Encrypted(name),
                    new Encrypted(password)
                    );

                return(Json(new { success = string.IsNullOrWhiteSpace(ar.Value), error = ar.Value, }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e) {
                ms_oLog.Error(e, "Failed to update linked HMRC account password for display name {0}.", name);
                return(Json(new { success = false, error = e.Message, }, JsonRequestBehavior.AllowGet));
            }     // try
        }         // Update
Пример #4
0
        public JsonResult QuestionForEmail(string email)
        {
            if (!ModelState.IsValid)
            {
                return(GetModelStateErrors(ModelState));
            }

            try {
                if (this.brokerHelper.IsBroker(email))
                {
                    return(Json(new { broker = true }, JsonRequestBehavior.AllowGet));
                }
            } catch (Exception e) {
                log.Warn(
                    e,
                    "Failed to check whether the email '{0}' is a broker email, continuing as a customer.",
                    email
                    );
            }             // try

            CustomerOrigin uiOrigin = UiCustomerOrigin.Get();

            try {
                StringActionResult sar = this.serviceClient.Instance.GetCustomerSecurityQuestion(
                    email,
                    uiOrigin.GetOrigin()
                    );

                if (string.IsNullOrWhiteSpace(sar.Value))
                {
                    return(Json(new {
                        error = "Security question not found for user " + email,
                    }, JsonRequestBehavior.AllowGet));
                }                 // if

                return(Json(new { question = sar.Value, }, JsonRequestBehavior.AllowGet));
            } catch (Exception e) {
                log.Alert(
                    e,
                    "Failed to detect security question for customer '{0}' with origin '{1}'.",
                    email,
                    uiOrigin.GetOrigin()
                    );
                return(Json(new { error = "User : '******' was not found" }, JsonRequestBehavior.AllowGet));
            }     // try
        }         // QuestionForEmail
Пример #5
0
        public JsonResult Send(string sPackage)
        {
            EchoSignEnvelope[] oPackage = JsonConvert.DeserializeObject <EchoSignEnvelope[]>(sPackage);

            if (oPackage == null)
            {
                Log.Debug("Could not extract e-sign package from {0}.", sPackage);
                return(Json(new { success = false, error = "Could not extract e-sign package from input.", }));
            }             // if

            if (oPackage.Length == 0)
            {
                Log.Debug("Empty e-sign package received: {0}.", sPackage);
                return(Json(new { success = false, error = "Empty e-sign package received.", }));
            }             // if

            EchoSignEnvelope[] oPackageToSend = oPackage.Where(x => x.IsValid).ToArray();

            if (oPackage.Length == 0)
            {
                Log.Debug("No envelopes are ready to be sent in: {0}.", string.Join("\n", (object[])oPackage));
                return(Json(new { success = false, error = "No envelopes are ready to be sent.", }));
            }             // if

            Log.Debug("Send for signature request:\n{0}", string.Join("\n", (object[])oPackageToSend));

            string sResult;

            try {
                StringActionResult sar = this.serviceClient.Instance.EsignSend(this.context.UserId, oPackageToSend);
                sResult = sar.Value;
            }
            catch (Exception e) {
                Log.Warn(e, "Failed to send a package for e-signing.");
                return(Json(new { success = false, error = "Failed to send a package for e-signing.", }));
            }             // try

            return(Json(new { success = string.IsNullOrWhiteSpace(sResult), error = sResult, }));
        }         // Send
Пример #6
0
        public JsonResult RestorePassword(string email = "", string answer = "")
        {
            if (!ModelState.IsValid)
            {
                return(GetModelStateErrors(ModelState));
            }

            if (string.IsNullOrWhiteSpace(answer))
            {
                throw new EmptyAnswerExeption("Answer is empty.");
            }

            CustomerOrigin uiOrigin = UiCustomerOrigin.Get();

            try {
                StringActionResult sar = this.serviceClient.Instance.ValidateSecurityAnswer(
                    email,
                    uiOrigin.GetOrigin(),
                    answer
                    );

                if (string.IsNullOrWhiteSpace(sar.Value))
                {
                    return(Json(new { result = true }, JsonRequestBehavior.AllowGet));
                }

                return(Json(new { error = "Wrong answer to secret question." }, JsonRequestBehavior.AllowGet));
            } catch (Exception e) {
                log.Alert(
                    e,
                    "Failed to validate an answer to security question for customer '{0}' with origin '{1}'.",
                    email,
                    uiOrigin.GetOrigin()
                    );

                return(Json(new { error = "Wrong answer to secret questions" }, JsonRequestBehavior.AllowGet));
            }     // try
        }         // RestorePassword
Пример #7
0
        public System.Web.Mvc.ActionResult FinishWizardLater()
        {
            var blm = new WizardBrokerLeadModel(Session);

            ms_oLog.Debug("Broker fill wizard later request: {0}", blm);

            if (blm.BrokerFillsForCustomer)
            {
                StringActionResult sar = null;

                try {
                    sar = this.m_oServiceClient.Instance.BrokerBackFromCustomerWizard(blm.LeadID);
                } catch (Exception e) {
                    ms_oLog.Warn(e, "Failed to retrieve broker details, falling back to customer's dashboard.");
                }                 // try

                if (sar == null)
                {
                    ms_oLog.Debug("Failed to retrieve broker details.");
                }
                else
                {
                    BrokerHelper.SetAuth(null, HttpContext);

                    ms_oLog.Debug("Restoring broker identity after filling customer wizard: '{0}'.", sar.Value);
                    BrokerHelper.SetAuth(sar.Value);

                    blm.Unset();
                    return(RedirectToAction("Index", "BrokerHome", new { Area = "Broker" }));
                }         // if
            }             // if

            ms_oLog.Debug("Broker fill wizard later request failed, redirecting back to customer wizard.");

            blm.Unset();
            return(RedirectToAction("Index", "Wizard", new { Area = "Customer" }));
        }         // FinishWizardLater
        public JsonResult ChangePassword(string oldPassword, string newPassword)
        {
            string sErrorMsg = null;
            bool   bSuccess  = false;

            try {
                StringActionResult sar = this.serviceClient.Instance.CustomerChangePassword(
                    this.context.User.Name,
                    UiCustomerOrigin.Get().GetOrigin(),
                    new DasKennwort(oldPassword),
                    new DasKennwort(newPassword)
                    );

                sErrorMsg = sar.Value;

                bSuccess = string.IsNullOrWhiteSpace(sErrorMsg);
            } catch (Exception e) {
                ms_oLog.Alert(e, "Failed to update password for customer '{0}'.", this.context.User.Name);
                sErrorMsg = "Failed to update password.";
                bSuccess  = false;
            }             // try

            return(Json(new { success = bSuccess, error = sErrorMsg, }));
        }         // ChangePassword