Ejemplo n.º 1
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
Ejemplo n.º 2
0
        public JsonResult SignUp(
            User model,
            string FirstName,
            string Surname,
            string signupPass1,
            string signupPass2,
            string securityQuestion,
            string mobilePhone,
            string mobileCode,
            string isInCaptchaMode,
            int whiteLabelId
            )
        {
            string    id          = Guid.NewGuid().ToString("N");
            const int idChunkSize = 4;

            string uniqueID = string.Join("-",
                                          Enumerable.Range(0, id.Length / idChunkSize).Select(i => id.Substring(i * idChunkSize, idChunkSize))
                                          );

            log.Debug("Sign up client attempt id: '{0}'...", uniqueID);

            this.cookiesToRemoveOnSignup.Clear();

            if (!ModelState.IsValid)
            {
                return(GetModelStateErrors(ModelState));
            }

            if (model.SecurityAnswer.Length > 199)
            {
                throw new Exception(DbStrings.MaximumAnswerLengthExceeded);
            }

            CustomerOrigin uiOrigin = UiCustomerOrigin.Get();

            string alibabaID = GetAndRemoveCookie("alibaba_id");

            if (uiOrigin.IsAlibaba() && string.IsNullOrWhiteSpace(alibabaID))
            {
                return(Json(new {
                    success = false,
                    errorMessage = "No Alibaba customer id provided.",
                }, JsonRequestBehavior.AllowGet));
            }             // if

            var blm = new WizardBrokerLeadModel(Session);

            CampaignSourceRef campaignSourceRef = null;

            if (!blm.BrokerFillsForCustomer)
            {
                campaignSourceRef = new CampaignSourceRef {
                    FContent = GetAndRemoveCookie("fcontent"),
                    FMedium  = GetAndRemoveCookie("fmedium"),
                    FName    = GetAndRemoveCookie("fname"),
                    FSource  = GetAndRemoveCookie("fsource"),
                    FTerm    = GetAndRemoveCookie("fterm"),
                    FUrl     = GetAndRemoveCookie("furl"),
                    FDate    = ToDate(GetAndRemoveCookie("fdate")),
                    RContent = GetAndRemoveCookie("rcontent"),
                    RMedium  = GetAndRemoveCookie("rmedium"),
                    RName    = GetAndRemoveCookie("rname"),
                    RSource  = GetAndRemoveCookie("rsource"),
                    RTerm    = GetAndRemoveCookie("rterm"),
                    RUrl     = GetAndRemoveCookie("rurl"),
                    RDate    = ToDate(GetAndRemoveCookie("rdate")),
                };
            }             // if

            string visitTimes = GetAndRemoveCookie("sourceref_time");

            var signupModel = new SignupCustomerMultiOriginModel {
                UserName               = model.EMail,
                Origin                 = uiOrigin.GetOrigin(),
                RawPassword            = new DasKennwort(signupPass1),
                RawPasswordAgain       = new DasKennwort(signupPass2),
                PasswordQuestion       = Convert.ToInt32(securityQuestion),
                PasswordAnswer         = model.SecurityAnswer,
                RemoteIp               = RemoteIp(),
                FirstName              = FirstName,
                LastName               = Surname,
                CaptchaMode            = isInCaptchaMode == "True",
                MobilePhone            = mobilePhone,
                MobileVerificationCode = mobileCode,
                BrokerFillsForCustomer = blm.BrokerFillsForCustomer,
                WhiteLabelID           = whiteLabelId,
                IsTest                 = (Request.Cookies["istest"] != null) ? true : (bool?)null,
                CampaignSourceRef      = campaignSourceRef,
                GoogleCookie           = blm.BrokerFillsForCustomer ? string.Empty : GetAndRemoveCookie("__utmz"),
                ReferenceSource        = blm.BrokerFillsForCustomer ? "Broker" : GetAndRemoveCookie("sourceref"),
                AlibabaID              = blm.BrokerFillsForCustomer ? null : GetAndRemoveCookie("alibaba_id"),
                ABTesting              = GetAndRemoveCookie("ezbobab"),
                VisitTimes             = visitTimes,
                FirstVisitTime         = HttpUtility.UrlDecode(visitTimes),
                RequestedLoanAmount    = GetAndRemoveCookie("loan_amount"),
                RequestedLoanTerm      = GetAndRemoveCookie("loan_period"),
                BrokerLeadID           = blm.LeadID,
                BrokerLeadEmail        = blm.LeadEmail,
                BrokerLeadFirstName    = blm.FirstName,
            };

            log.Debug(
                "Sign up client attempt id: '{0}', model is {1}.",
                uniqueID,
                signupModel.ToLogStr()
                );

            try {
                log.Debug("Sign up client attempt id: '{0}', requesting backend sign up.", uniqueID);

                UserLoginActionResult signupResult = this.serviceClient.Instance.SignupCustomerMultiOrigin(signupModel);

                log.Debug("Sign up client attempt id: '{0}', backend sign up complete.", uniqueID);

                MembershipCreateStatus status = (MembershipCreateStatus)Enum.Parse(
                    typeof(MembershipCreateStatus),
                    signupResult.Status
                    );

                log.Debug("Sign up client attempt id: '{0}', status is {1}.", uniqueID, status);

                if (status == MembershipCreateStatus.DuplicateEmail)
                {
                    return(Json(
                               new {
                        success = false,
                        errorMessage = signupResult.ErrorMessage,
                    },
                               JsonRequestBehavior.AllowGet
                               ));
                }                 // if

                if ((status != MembershipCreateStatus.Success) || !string.IsNullOrWhiteSpace(signupResult.ErrorMessage))
                {
                    throw new Exception(string.IsNullOrWhiteSpace(signupResult.ErrorMessage)
                                                ? string.Format("Failed to sign up (error code is '{0}').", uniqueID)
                                                : signupResult.ErrorMessage
                                        );
                }                 // if

                ObjectFactory.GetInstance <IEzbobWorkplaceContext>().SessionId =
                    signupResult.SessionID.ToString(CultureInfo.InvariantCulture);

                Session["UserSessionId"] = signupResult.SessionID;

                this.context.SetSessionOrigin(uiOrigin.GetOrigin());
                FormsAuthentication.SetAuthCookie(model.EMail, false);
                HttpContext.User = new GenericPrincipal(new GenericIdentity(model.EMail), new[] { "Customer" });

                RemoveCookiesOnSignup();

                log.Debug("Sign up client attempt id: '{0}', sign up complete.", uniqueID);

                return(Json(
                           new {
                    success = true,
                    antiforgery_token = AntiForgery.GetHtml().ToString(),
                    refNumber = signupResult.RefNumber,
                },
                           JsonRequestBehavior.AllowGet
                           ));
            } catch (Exception e) {
                log.Alert(e, "Failed to sign up, client attempt id: {0}.", uniqueID);

                return(Json(
                           new {
                    success = false,
                    errorMessage = string.Format(
                        "Failed to sign up, please call support (error code is '{0}').",
                        uniqueID
                        ),
                },
                           JsonRequestBehavior.AllowGet
                           ));
            }     // try
        }         // SignUp