Exemplo n.º 1
0
 public void Should_return_the_mapped_object()
 {
     var mapper = new UrlMapper<string>();
     mapper.AddUrl("/hello/index","chris");
     string matched = mapper.Map("/hello/index");
     matched.ShouldEqual("chris");
 }
Exemplo n.º 2
0
 public Task Enable()
 {
     UrlMapper.RegisterPluginExtension(".lua", this);
     UrlMapper.RegisterIndexFile("index.lua");
     ScriptLoader.Initialize();
     return(Task.CompletedTask);
 }
Exemplo n.º 3
0
        public async Task <OrignalUrlResponse> OrignalURL(string Url)
        {
            var Key = await _helper.Decode(Url);

            UrlInfo urlInfo = new UrlInfo();

            try
            {
                urlInfo = await _dbContext.Urls.Where(x => x.Key == Key).FirstOrDefaultAsync();

                if (urlInfo == null)
                {
                    //TODO Add to error list
                    throw new ApiException("Invalid Input");
                }
                urlInfo.Clicks     += 1;
                urlInfo.LastClicked = DateTime.Now;
                await _dbContext.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                return(new OrignalUrlResponse
                {
                    Message = ex.Message
                });
            }

            var response = UrlMapper.MapUrlInfoToOrignalUrlResponse(urlInfo);

            return(response);
        }
Exemplo n.º 4
0
        public async Task <ShortenUrlResponse> ShortenURL(UrlInfo input)
        {
            int Id = await SaveToDbAndGetKey(input);

            input.Key     = Id + 1000000;
            input.UrlHash = await _helper.Encode(input.Key);

            input.Title = await _helper.GetTitle(input.Url);

            //TODO research about date time
            input.CreatedAt = DateTime.Now;
            try
            {
                await _dbContext.SaveChangesAsync();
            }
            catch (Exception)
            {
                return(new ShortenUrlResponse
                {
                    Message = "Unable to save to Db"
                });
            }
            var response = UrlMapper.MapUrlInfoToShortenUrlResponse(input);

            return(response);
        }
Exemplo n.º 5
0
 public Task Disable()
 {
     UrlMapper.UnRegisterPluginExtension(".lua");
     UrlMapper.UnRegisterIndexFile("index.lua");
     LuaLowLevelAccess.ClearLowLevelClasses();
     return(Task.CompletedTask);
 }
Exemplo n.º 6
0
        //
        // GET: /Artist/Details/5

        public ActionResult Details(int id = invalidId)
        {
            if (id == invalidId)
            {
                return(HttpNotFound());
            }

            WebHelper.VerifyUserAgent(Request);

            var model = queries.GetDetails(id, GetHostnameForValidHit());

            var hasDescription = !model.Description.IsEmpty;
            var prop           = PageProperties;

            prop.GlobalSearchType          = EntryType.Artist;
            prop.Title                     = model.Name;
            prop.Subtitle                  = string.Format("({0})", Translate.ArtistTypeName(model.ArtistType));
            prop.Description               = new ArtistDescriptionGenerator().GenerateDescription(model, markdownParser.GetPlainText(model.Description.EnglishOrOriginal), Translate.ArtistTypeNames);
            prop.CanonicalUrl              = UrlMapper.FullAbsolute(Url.Action("Details", new { id }));
            prop.OpenGraph.Image           = Url.ImageThumb(model, Model.Domain.Images.ImageSize.Original, fullUrl: true);
            prop.OpenGraph.Title           = hasDescription ? string.Format("{0} ({1})", model.Name, Translate.ArtistTypeName(model.ArtistType)) : model.Name;
            prop.OpenGraph.ShowTwitterCard = true;

            return(View(model));
        }
Exemplo n.º 7
0
 public override void EstablishContext()
 {
     _mapper = new UrlMapper<string>();
     foreach(var url in testUrls.Keys.Reverse())
     {
         _mapper.AddUrl(url, testUrls[url]);
     }
 }
Exemplo n.º 8
0
        public void Call_on_empty_map_defaults_to_status_404()
        {
            var map = new Dictionary <string, AppFunc>();
            var app = UrlMapper.Create(NotFound, map);
            var env = CreateEmptyEnvironment();

            app(env).Wait();
            Assert.That(env.Get <int>("owin.ResponseStatusCode"), Is.EqualTo(404));
        }
Exemplo n.º 9
0
        public ActionResult ChangePassword()
        {
            var context = new SitecoreContext();
            var model   = context.GetCurrentItem <ChangePassword>();

            model.isPasswordPolicyFail  = false;
            model.isShowPasswordUpdated = false;
            SitecoreProfileService scProfileService = new SitecoreProfileService();

            if (Session["isShowPasswordUpdated"] != null)
            {
                model.isShowPasswordUpdated      = (bool)Session["isShowPasswordUpdated"];
                Session["isShowPasswordUpdated"] = null;
            }
            if (Session["ChangePasswordError"] != null)
            {
                List <ModelErrorCollection> allerror = (List <ModelErrorCollection>)Session["ChangePasswordError"];
                foreach (var item in allerror)
                {
                    foreach (var subItem in item)
                    {
                        ModelState.AddModelError("", subItem.ErrorMessage.ToString());
                    }
                }

                Session["ChangePasswordError"] = null;
            }

            if (scProfileService.CheckForDisableAccountUpdates())
            {
                model.isAccountLocked = true;
                ModelState.AddModelError("", Sitecore.Globalization.Translate.Text("Profile_AccountNoUpdateAllow"));
            }
            else
            {
                model.isAccountLocked = false;
                if (Request.QueryString["PasswordRuleFail"] != "" && Request.QueryString["PasswordRuleFail"] == "true")
                {
                    var            membershipUser = scProfileService.GetCurrentMembershipUser();
                    ProfileService profileService = new ProfileService();

                    profileService.SetLoginWaitContext(membershipUser.Email, scProfileService.RemoveDomainToUserName(membershipUser.UserName), null, null);

                    model.isPasswordPolicyFail = true;
                }
                else
                {
                    //If the user acecss this page using Self service they MUST be authenticated If not we send them back to the Login page
                    BlueGreenContext bgContext = new BlueGreenContext();
                    if (!bgContext.IsAuthenticated)
                    {
                        Response.Redirect(UrlMapper.Map(model.SiteSettings.SignInPage.Url));
                    }
                }
            }
            return(View(model));
        }
Exemplo n.º 10
0
 public override void EstablishContext()
 {
     _mapper = new UrlMapper<string>();
     _mapper.AddUrl("/blogs/comments", "allcomments");
     _mapper.AddUrl("/blogs/{year}/{month}/{day}", "blogurl");
     _mapper.AddUrl("/users/{username}", "userurl");
     _mapper.AddUrl("/", "defaulturl");
     _mapper.AddUrl("/blogs/comments/{id}","onecomment");
     _mapper.AddUrl("/users/list", "listuserurl");
 }
Exemplo n.º 11
0
 public void Start()
 {
     _availableEngines = new Dictionary <string, Type>();
     UrlMapper.RegisterIndexFile("index.html");
     UrlMapper.RegisterIndexFile("index.htm");
     RegisterEngine("http", typeof(HttpEngine));
     _engines = new List <Engine>();
     Logger.Info("Starting HtcSharp...");
     Logger.Info("Loading Configuration...");
     AspNetConfigPath = Path.Combine(Path.GetDirectoryName(_configPath), "aspnet-appsettings.json");
     try {
         if (!File.Exists(_configPath))
         {
             IoUtils.CreateHtcConfig(_configPath);
         }
         _config = IoUtils.GetJsonFile(_configPath);
         if (!File.Exists(AspNetConfigPath))
         {
             IoUtils.CreateAspConfig(AspNetConfigPath);
         }
         PluginsPath     = _config.GetValue("PluginsPath", StringComparison.CurrentCultureIgnoreCase)?.Value <string>() ?? Path.Combine(Directory.GetCurrentDirectory(), @"plugins/");
         PluginsPath     = IoUtils.ReplacePathTags(PluginsPath);
         _errorPagesPath = _config.GetValue("ErrorPagesPath", StringComparison.CurrentCultureIgnoreCase)?.Value <string>() ?? Path.Combine(Directory.GetCurrentDirectory(), @"error-pages/");
         _errorPagesPath = IoUtils.ReplacePathTags(_errorPagesPath);
         IsDebug         = _config.GetValue("Debug", StringComparison.CurrentCultureIgnoreCase)?.Value <bool>() == true;
         if (!Directory.Exists(PluginsPath))
         {
             Directory.CreateDirectory(PluginsPath);
         }
         if (!Directory.Exists(_errorPagesPath))
         {
             Directory.CreateDirectory(_errorPagesPath);
         }
     } catch (Exception ex) {
         Logger.Error("Failed to load configuration!", ex);
         return;
     }
     RegisterErrorPages();
     PluginsManager = new PluginManager();
     PluginsManager.LoadPlugins(PluginsPath);
     PluginsManager.Call_OnLoad();
     LoadEngines();
     foreach (var engine in _engines)
     {
         try {
             Logger.Info($"Starting Engine: '{engine.GetType().Name}'");
             engine.Start();
         } catch (Exception ex) {
             Logger.Error($"Failed to start Engine: '{engine.GetType().Name}'", ex);
         }
     }
     IsStopped = true;
     PluginsManager.Call_OnEnable();
     Logger.Info("HTCServer is now running!");
 }
Exemplo n.º 12
0
        public ActionResult SignInSitecore(SignIn signIn)
        {
            //Validate if the fields are populated
            if (string.IsNullOrEmpty(signIn.txtEmail) || string.IsNullOrEmpty(signIn.txtPassword))
            {
                var context = new SitecoreContext();
                var model   = context.GetCurrentItem <SignIn>();
                Response.Redirect(UrlMapper.Map(model.SiteSettings.SignInHelpPage.Url));
            }

            //Remove invalid characters from the Email
            if (signIn.txtEmail.Contains(","))
            {
                Session["SignInUiError"] = Sitecore.Globalization.Translate.Text("Profile_AccountNotFound");
                return(base.Index());
            }

            ActionResult result         = null;
            var          profileservice = new ProfileService();

            var loginResponse = profileservice.LoginUser(signIn.txtEmail, signIn.txtPassword, null, null, null, null);

            if (loginResponse.IsSuccessfull)
            {
                var context = new SitecoreContext();
                var model   = context.GetCurrentItem <SignIn>();
                //TODO: Enable Below code once owner object is completely ready
                //RedirectRegistrationConfirmation(UrlMapper.Map(registrationInfo.PostbackSuccessPageUrl));
                Response.Redirect(UrlMapper.Map(model.SiteSettings.SignInWaitPage.Url));
            }
            else
            {
                var context = new SitecoreContext();
                var model   = context.GetCurrentItem <SignIn>();
                if (loginResponse.errorCode == SignInResponse.errors.InvalidPassword)
                {
                    //Session["PasswordRuleFail"] = "true";  //TODO find another way to get this working
                    Response.Redirect("/mybluegreen/my-account/Change-Password?PasswordRuleFail=true", true);  //TODO define const for URL
                }
                SitecoreProfileService scProfileService = new SitecoreProfileService();
                var scUserName = scProfileService.GetUserByEmail(signIn.txtEmail);
                if (loginResponse.errorCode == SignInResponse.errors.LockedAccount && !scProfileService.CheckForDisableAccountUpdates(scUserName))
                {
                    Session["SignInUiError"] = Sitecore.Globalization.Translate.Text("Profile_AccountLocked");
                }
                else
                {
                    Session["SignInUiError"] = Sitecore.Globalization.Translate.Text("Profile_AccountNotFound");
                }
                result = base.Index();
            }

            return(result);
        }
Exemplo n.º 13
0
 public Task Load(JObject config, Core.Logging.Abstractions.ILogger logger)
 {
     _logger = logger;
     Configure(config);
     UrlMapper.RegisterIndexFile("index.html");
     UrlMapper.RegisterIndexFile("index.htm");
     _serviceProvider = SetupServiceCollection().BuildServiceProvider();
     _loggerFactory   = LoggerFactory.Create(builder => {
         builder.AddProvider(new HtcLoggerProvider(_logger));
     });
     _socketTransportFactory = new SocketTransportFactory(GetSocketTransportOptions(config), _loggerFactory);
     _kestrelServer          = new KestrelServer(GetKestrelServerOptions(config, _serviceProvider), _socketTransportFactory, _loggerFactory);
     return(Task.CompletedTask);
 }
Exemplo n.º 14
0
 public Task Disable()
 {
     UrlMapper.UnRegisterPluginPage("/api/start");
     UrlMapper.UnRegisterPluginPage("/api/stop");
     UrlMapper.UnRegisterPluginPage("/api/restart");
     UrlMapper.UnRegisterPluginPage("/api/kill");
     UrlMapper.UnRegisterPluginPage("/api/stats");
     UrlMapper.UnRegisterPluginPage("/api/server");
     UrlMapper.UnRegisterPluginPage("/api/servers");
     UrlMapper.UnRegisterPluginPage("/api/command");
     UrlMapper.UnRegisterPluginPage("/api/login");
     SessionManager.Stop();
     ServerManager.Stop();
     return(Task.CompletedTask);
 }
Exemplo n.º 15
0
        public ActionResult PaymentOptions()
        {
            BlueGreenContext bg = new BlueGreenContext();

            if (bg?.bxgOwner == null)
            {
                return(Redirect(UrlMapper.Map(SiteSettings.SignInPage.Url)));
            }
            var accountInfo    = Session["AccountDetails"] as AccountViewModel;
            var paymentOptions = GetDataSourceItem <PaymentOptions>();

            paymentOptions.AccountInfo = accountInfo;
            ViewBag.TotalDue           = Session["TotalDue"];
            return(View(paymentOptions));
        }
Exemplo n.º 16
0
        public async Task Enable()
        {
            UrlMapper.RegisterPluginPage("/api/start", this);
            UrlMapper.RegisterPluginPage("/api/stop", this);
            UrlMapper.RegisterPluginPage("/api/restart", this);
            UrlMapper.RegisterPluginPage("/api/kill", this);
            UrlMapper.RegisterPluginPage("/api/stats", this);
            UrlMapper.RegisterPluginPage("/api/server", this);
            UrlMapper.RegisterPluginPage("/api/servers", this);
            UrlMapper.RegisterPluginPage("/api/command", this);
            UrlMapper.RegisterPluginPage("/api/login", this);
            await ServerManager.LoadServers();

            SessionManager.Start();
            ServerManager.Start();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Payment Reminder Message
        /// </summary>
        /// <returns>View from </returns>
        // GET: Payments
        public ActionResult PaymentReminder()
        {
            AccountsBalanceHelper accountsBalanceHelper = new AccountsBalanceHelper();
            BlueGreenContext      bg = new BlueGreenContext();

            if (bg?.bxgOwner == null)
            {
                return(Redirect(UrlMapper.Map(SiteSettings.SignInPage.Url)));
            }

            if (bg.IsInstallmentPlan())
            {
                return(RedirectToActionPermanent("AccountsBalance"));
            }

            var model = accountsBalanceHelper.GetPaymentContentFromPaymentConfig(bg);

            return(View(model));
        }
Exemplo n.º 18
0
        public ActionResult ShowWidget()
        {
            var model = GetLayoutItem <SideWidget>();
            BlueGreenContext userContext = new BlueGreenContext();

            if (SitecoreUtils.EvaluateRules(model.RestrictionRule, model.InnerItem))
            {
                foreach (var item in model.WidgetContents)
                {
                    item.isVisible = true;
                    if (SitecoreUtils.EvaluateRules(item.RestrictionRule, item.InnerItem))
                    {
                        if (item.WidgetLink != null)
                        {
                            item.WidgetLink.Url = UrlMapper.Map(item.WidgetLink.Url);
                        }
                        if (item.SubWidgetLink != null)
                        {
                            item.SubWidgetLink.Url = UrlMapper.Map(item.SubWidgetLink.Url);
                        }
                        if (item.SubWidgetText != null)
                        {
                            item.SubWidgetText = UpdateText(item.SubWidgetText, userContext);
                        }
                        if (item.SubWidgetLink != null && !string.IsNullOrEmpty(item.SubWidgetLink.Text))
                        {
                            item.SubWidgetLink.Text = UpdateText(item.SubWidgetLink.Text, userContext);
                        }
                    }

                    else
                    {
                        item.isVisible = false;
                    }
                }
            }
            else
            {
                model.WidgetContents = null;
                //model = null;
            }
            return(View(model));
        }
Exemplo n.º 19
0
        private void CheckForTravelerPlusMembershipAndRedirect(RewardsSections model)
        {
            // Check for Travelerplus Expiry .Copied Logic from Legacy TravelerPlus Home page
            if (model.InnerItem.ID.ToString().Equals("{536E4650-A734-4D8B-AFF6-62518271C2B5}", StringComparison.CurrentCultureIgnoreCase))
            {
                BlueGreenContext bgContext = new BlueGreenContext();
                string           targetUrl = string.Empty;

                if (bgContext != null && bgContext.GetOwnerType() == "Travelerplus")
                {
                    if (bgContext.IsTPExpired && bgContext.IsAccountExpired)
                    {
                        targetUrl = UrlMapper.Map("https://www.bluegreenowner.com/TravelerPlus/owner/ownerrenewal.aspx");
                        Response.RedirectPermanent(targetUrl, true);
                    }
                }
                else
                {
                    targetUrl = UrlMapper.Map("https://www.bluegreenowner.com/owner/vcTravelerPlus.aspx");
                    Response.RedirectPermanent(targetUrl, true);
                }
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Sign in user from external system like VSSA
        /// </summary>
        public void SignInProcess()
        {
            var email        = Request.Form["txtEmail"].Trim();
            var ownerArvact  = Request.Form["ownerARVACT"].Trim();
            var AgentLoginID = Request.Form["AgentLoginID"].Trim();
            var fromVSSA     = Request.Form["fromVSSA"];
            var ownerACCT    = Request.Form["ownerACCT"];

            var profileservice = new ProfileService();
            var response       = profileservice.LoginUser(email, null, ownerArvact, fromVSSA, ownerACCT, AgentLoginID);

            if (response.IsSuccessfull)
            {
                var context = new SitecoreContext();
                var model   = context.GetCurrentItem <SignIn>();
                Response.Redirect(UrlMapper.Map(model.SiteSettings.SignInWaitPage.Url));
            }
            else
            {
                var context = new SitecoreContext();
                var model   = context.GetCurrentItem <SignIn>();
                Response.Redirect(UrlMapper.Map(model.SiteSettings.SignInHelpPage.Url));
            }
        }
Exemplo n.º 21
0
 public void OnEnable()
 {
     UrlMapper.RegisterPluginExtension(".php", this);
     UrlMapper.RegisterIndexFile("index.php");
 }
Exemplo n.º 22
0
 public void OnDisable()
 {
     UrlMapper.UnRegisterPluginExtension(".php");
     UrlMapper.UnRegisterIndexFile("index.php");
 }
Exemplo n.º 23
0
        public ActionResult ChangePasswordProcess(ChangePassword changePassword)
        {
            var            context = new SitecoreContext();
            ChangePassword model   = context.GetCurrentItem <ChangePassword>();

            if (!changePassword.isPasswordPolicyFail && !Context.User.IsAuthenticated)
            {
                Response.Redirect(UrlMapper.Map(model.SiteSettings.SignInPage.Url));
                return(null);
            }

            model.isPasswordPolicyFail = changePassword.isPasswordPolicyFail;  //Reset the default value
            if (ModelState.IsValid)
            {
                if (changePassword.txtNewPassword.Contains(" "))
                {
                    ModelState.AddModelError("", Sitecore.Globalization.Translate.Text("Profile_PasswordInvalid"));
                }
                else
                {
                    SitecoreProfileService scProfileService = new SitecoreProfileService();

                    var membershipUser = scProfileService.GetCurrentMembershipUser();
                    if (membershipUser.ChangePassword(changePassword.txtCurrentPassword, changePassword.txtNewPassword))
                    {
                        EmailManager.UpdatePassword(membershipUser.UserName, membershipUser.Email);
                        if (changePassword.isPasswordPolicyFail)// Need to Complete the login Proces
                        {
                            Response.Redirect(UrlMapper.Map(model.SiteSettings.SignInWaitPage.Url));
                            return(null);
                        }
                        else
                        {
                            Session["isShowPasswordUpdated"] = true;
                            //  model.isShowPasswordUpdated = true;
                            return(Redirect(UrlMapper.Map(SitecoreUtils.GetPageUrl(SitecoreItemReferences.ChangePasswordPageId))));
                        }
                    }
                    else
                    {
                        MembershipUser user = Membership.GetUser(Context.User.Name, false);
                        if (user != null)
                        {
                            if (user.IsLockedOut)
                            {
                                var scUser = scProfileService.GetUser(Context.User.Name);
                                Components.EmailManager.ResetEmail(Context.User.Name, scUser.Profile.Email);
                                if (scUser != null && !scProfileService.CheckForPasswordLockedEmail(scUser))
                                {
                                    scUser.Profile.SetCustomProperty(SitecoreProfileService.PasswordLockedEmailId, "1");
                                    scUser.Profile.Save();
                                }
                                Session["SignInUiError"] = Sitecore.Globalization.Translate.Text("Profile_AccountLocked");
                                return(Redirect(UrlMapper.Map(model.SiteSettings.SignInPage.Url)));
                            }
                        }
                        ModelState.AddModelError("", Sitecore.Globalization.Translate.Text("CurrentPassword_Current_NotCorrect"));
                    }
                }
            }


            var errors = ModelState.Select(x => x.Value.Errors)
                         .Where(y => y.Count > 0)
                         .ToList();

            if (errors != null && errors.Count > 0)
            {
                Session["ChangePasswordError"] = errors;
            }
            if (changePassword.isPasswordPolicyFail)
            {
                return(Redirect(UrlMapper.Map(SitecoreUtils.GetPageUrl(SitecoreItemReferences.ChangePasswordPageId)) + "?PasswordRuleFail=true"));
            }
            else
            {
                return(Redirect(UrlMapper.Map(SitecoreUtils.GetPageUrl(SitecoreItemReferences.ChangePasswordPageId))));
            }
            //return View(model);
        }
Exemplo n.º 24
0
        public ActionResult ResetPasswordProcess(ResetPassword resetPassword)
        {
            bool isValid = true;

            if (resetPassword.txtNewPassword.Contains(" "))
            {
                if (ModelState.IsValid)
                {
                    ModelState.AddModelError("", Sitecore.Globalization.Translate.Text("Profile_PasswordInvalid"));
                }
                isValid = false;
            }

            if (ModelState.IsValid && isValid)
            {
                SitecoreProfileService scProfileService = new SitecoreProfileService();
                var            scUserName = scProfileService.GetUserByEmail(resetPassword.email);
                MembershipUser user       = scProfileService.GetMembershipUser(scUserName);
                if (user != null)
                {
                    user.UnlockUser();

                    scProfileService.ResetFlagPasswordLockedEmail(scUserName);
                    ProfileService profileService = new ProfileService();
                    if (!user.ChangePassword(user.ResetPassword(), resetPassword.txtNewPassword))
                    {
                        ModelState.AddModelError("", "ERROR");  //todo add error
                        return(base.Index());
                    }
                    else
                    {
                        EmailManager.UpdatePassword(scUserName, resetPassword.email);

                        var response = profileService.LoginUser(resetPassword.email, resetPassword.txtNewPassword, null, null, null, null);
                        if (response.IsSuccessfull)
                        {
                            var context = new SitecoreContext();
                            var model   = context.GetCurrentItem <SignIn>();
                            profileService.SetLoginWaitContext(resetPassword.email, null, null, null);
                            Response.Redirect(UrlMapper.Map(model.SiteSettings.SignInWaitPage.Url));
                        }
                        else
                        {
                            ModelState.AddModelError("", "ERROR");  //todo add error
                            return(base.Index());
                        }
                    }
                }
            }
            else
            {
                var errors = ModelState.Select(x => x.Value.Errors)
                             .Where(y => y.Count > 0)
                             .ToList();

                Session["ResetPasswordError"] = errors;

                Response.Redirect(string.Format("/reset-password?email={0}&resetid={1}", resetPassword.email, resetPassword.resetid));
            }
            return(null);
        }
Exemplo n.º 25
0
        public ActionResult Register(Registration registrationInfo)
        {
            var profileservice = new ProfileService();

            if (registrationInfo.btnSubmit == "action:lookup")
            {
                foreach (var modelValue in ModelState.Values)
                {
                    modelValue.Errors.Clear();
                }
                if (string.IsNullOrEmpty(registrationInfo.txtLookupSSN) || string.IsNullOrEmpty(registrationInfo.txtLookupPhone))
                {
                    ModelState.AddModelError("", Sitecore.Globalization.Translate.Text("Register_AccountNotFound"));
                }
                else
                {
                    var ownerId = profileservice.GetOwnerNumber(registrationInfo.txtLookupSSN, registrationInfo.txtLookupPhone);

                    if (string.IsNullOrEmpty(ownerId))
                    {
                        ModelState.AddModelError("", Sitecore.Globalization.Translate.Text("Register_AccountNotFound"));
                    }
                    else
                    {
                        ValueProviderResult temp = new ValueProviderResult(ownerId, ownerId, CultureInfo.InvariantCulture);
                        ModelState["txtOwnerId"].Value = temp;
                    }
                }
            }
            else if (registrationInfo.btnSubmit == "action:register")
            {
                if (ModelState.IsValid)
                {
                    if (registrationInfo.txtPassword.Contains(" "))
                    {
                        ModelState.AddModelError("", Sitecore.Globalization.Translate.Text("Profile_PasswordInvalid"));
                    }
                    else
                    {
                        RegisterServiceModel   serviceModel     = new Services.RegisterServiceModel();
                        SitecoreProfileService scProfileService = new SitecoreProfileService();
                        ProfileService         profileService   = new ProfileService();

                        var scUserName = scProfileService.AddDomainToUserName(registrationInfo.txtOwnerId);

                        if (scProfileService.SitecoreExists(scUserName))
                        {
                            var user = scProfileService.GetUser(scUserName);


                            if (user.Profile.Email == registrationInfo.txtAcctEmail)
                            {
                                ModelState.AddModelError("", Sitecore.Globalization.Translate.Text("Register_EmailAlreadyRestierToSameOwner"));
                            }
                            else
                            {
                                ModelState.AddModelError("", Sitecore.Globalization.Translate.Text("Register_OwnerAlreadyRegister"));
                            }
                        }
                        else
                        {
                            bool allowRegistration = false;
                            var  username          = scProfileService.GetUserByEmail(registrationInfo.txtAcctEmail);
                            if (string.IsNullOrEmpty(username))
                            {
                                var legacyUser = profileService.GetOwnerDemographic(registrationInfo.txtAcctEmail, null);
                                if (legacyUser == null)
                                {
                                    allowRegistration = true;
                                }
                                else if (legacyUser.OwnerId == registrationInfo.txtOwnerId)
                                {
                                    allowRegistration = true;
                                }
                            }
                            //Verify if the email already exists

                            if (allowRegistration)
                            {
                                serviceModel.Email    = registrationInfo.txtAcctEmail;
                                serviceModel.OwnerId  = registrationInfo.txtOwnerId;
                                serviceModel.Password = registrationInfo.txtPassword;
                                serviceModel.Phone    = registrationInfo.txtPhone;
                                serviceModel.SSN      = registrationInfo.txtSSN;

                                if (profileservice.Register(serviceModel))
                                {
                                    var loginResponse = profileservice.LoginUser(registrationInfo.txtAcctEmail, registrationInfo.txtPassword, null, null, null, null);

                                    Session["LoginEmail"]            = registrationInfo.txtAcctEmail;
                                    Session["LoginPassword"]         = registrationInfo.txtPassword;
                                    Session["EnrollAcctNo"]          = registrationInfo.txtOwnerId;
                                    Session["ownerACCT"]             = registrationInfo.txtOwnerId;
                                    Session["ownerRegisterReferrer"] = "Register";
                                    Response.Redirect(UrlMapper.Map(registrationInfo.PostbackSuccessPageUrl), false);
                                    return(null);
                                    //RedirectRegistrationConfirmation(UrlMapper.Map(registrationInfo.PostbackSuccessPageUrl));
                                }
                                else
                                {
                                    ViewData["ShowUnsuccessMessage"] = "true";
                                }
                            }
                            else
                            {
                                ModelState.AddModelError("", Sitecore.Globalization.Translate.Text("Register_EmailMustBeUnique"));
                            }
                        }
                    }
                }
            }
            return(base.Index());
        }
 public ShortUrlCreatorController(UrlMapper urlMapper)
 {
     this.urlMapper = urlMapper;
 }
Exemplo n.º 27
0
 public void OnDisable()
 {
     UrlMapper.UnRegisterPluginExtension(".lua");
     UrlMapper.UnRegisterIndexFile("index.lua");
     LuaLowLevelAccess.ClearLowLevelClasses();
 }
Exemplo n.º 28
0
        public ActionResult MyContactUpdate(MyProfileResponseParameters model)
        {
            Session["ChangedCountry"]    = null;
            ViewData["SuggestedAddress"] = null;
            MyProfileResponseParameters Suggestion = new MyProfileResponseParameters();
            ProfileService psService = new ProfileService();

            if (ModelState.IsValid)
            {
                if (!model.Address_Country.Equals("us", StringComparison.CurrentCultureIgnoreCase))
                {
                    model.Address_City    = "";
                    model.Address_State   = "";
                    model.Address_ZipCode = "";
                }

                if (model.correct_address != null && Session["suggestion"] != null)
                {
                    var objectToConsider = model.correct_address == "no" ? (MyProfileResponseParameters)Session["suggestion"] : model;
                    objectToConsider.isPaperLessSelected = model.isPaperLessSelected;
                    var listOfServiceErrors = psService.UpdateProfileEmailAndDemoGraphics(objectToConsider);
                    if (listOfServiceErrors.Count > 0)
                    {
                        if (listOfServiceErrors.Count == 1 && listOfServiceErrors.FirstOrDefault().ErrorMessage == "ShowUnsuccessMessage")
                        {
                            //Generic message Caused due to network issues
                            ViewData["ShowUnsuccessMessage"] = "true";
                        }
                        else
                        {
                            foreach (var vi in listOfServiceErrors)
                            {
                                ModelState.AddModelError("", vi.ErrorMessage);
                            }
                        }
                    }
                    else
                    {
                        ViewData["ShowSuccessMessage"] = "true";
                        ModelState.Clear();
                    }
                    ViewData["SuggestedAddress"] = null;

                    if (!string.IsNullOrEmpty(model.successPageUrl) && (string)ViewData["ShowSuccessMessage"] == "true")
                    {
                        RedirectToRegistrationSuccess(UrlMapper.Map(model.successPageUrl));
                        return(null);
                    }
                    else
                    {
                        return(base.Index());
                    }
                }

                var listOfError = ValidationUtils.GetMyProfileViolations(model);
                if (listOfError.Count == 0 && model.Address_Country.Equals("us", StringComparison.CurrentCultureIgnoreCase))
                {
                    listOfError           = ValidationUtils.GetMelissaLookUpViolations(model, ref Suggestion);
                    Session["suggestion"] = Suggestion;
                    if (!string.IsNullOrEmpty(Suggestion.Address_AddressLine1))
                    {
                        ViewData["SuggestedAddress"]       = "true";
                        ViewData["SuggestedAddressDetail"] = ValidationUtils.AddressSuggestionFormat(Suggestion);
                        ViewData["ActualAddressDetail"]    = ValidationUtils.AddressSuggestionFormat(model);
                    }
                    else
                    {
                        if (listOfError.Count == 0)
                        {
                            ViewData["SuggestedAddress"] = null;
                        }
                        else
                        {
                            ViewData["SuggestedAddress"]    = "false";
                            ViewData["ActualAddressDetail"] = ValidationUtils.AddressSuggestionFormat(model);
                        }
                    }
                }
                if (listOfError.Count > 0)
                {
                    Session["ChangedCountry"] = model.Address_Country;
                    foreach (var vi in listOfError)
                    {
                        ModelState.AddModelError("", vi.ErrorMessage);
                    }
                }
                else
                {
                    ViewData["SuggestedAddress"] = ViewData["SuggestedAddress"] == null ? null : ViewData["SuggestedAddress"];
                    if (ViewData["SuggestedAddress"] == null || ViewData["SuggestedAddress"].ToString() == "false")
                    {
                        var listOfServiceErrors = psService.UpdateProfileEmailAndDemoGraphics(model);
                        if (listOfServiceErrors.Count > 0)
                        {
                            if (listOfServiceErrors.Count == 1 && listOfServiceErrors.FirstOrDefault().ErrorMessage == "ShowUnsuccessMessage")
                            {
                                //Generic message Caused due to network issues
                                ViewData["ShowUnsuccessMessage"] = "true";
                            }
                            else
                            {
                                foreach (var vi in listOfServiceErrors)
                                {
                                    ModelState.AddModelError("", vi.ErrorMessage);
                                }
                            }
                        }
                        else
                        {
                            ViewData["ShowSuccessMessage"] = "true";
                            ModelState.Clear();
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(model.successPageUrl) && (string)ViewData["ShowSuccessMessage"] == "true")
            {
                RedirectToRegistrationSuccess(UrlMapper.Map(model.successPageUrl));
                return(null);
            }
            else
            {
                return(base.Index());
            }
        }
Exemplo n.º 29
0
 public void OnEnable()
 {
     UrlMapper.RegisterPluginExtension(".lua", this);
     UrlMapper.RegisterIndexFile("index.lua");
     ScriptLoader.Initialize();
 }
Exemplo n.º 30
0
 public Task Disable()
 {
     UrlMapper.UnRegisterPluginExtension(".php");
     UrlMapper.UnRegisterIndexFile("index.php");
     return(Task.CompletedTask);
 }