public void Register()
        {
            ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
            configurationBuilder.SetBasePath(System.IO.Directory.GetCurrentDirectory());
            configurationBuilder.AddJsonFile("appsettings.json");
            IConfigurationRoot configurationRoot = configurationBuilder.Build();

            ELSOptions eLSOptions = configurationRoot.GetSection("els").Get<ELSOptions>();
            CaptchaToken captchaToken = configurationRoot.GetSection("reCaptchaToken").Get<CaptchaToken>();

            TestELSMemberRepository testELSMemberRepository = new TestELSMemberRepository(eLSOptions);
         
            MembersController controller = new MembersController(testELSMemberRepository);
            controller.ControllerContext = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();
            controller.ControllerContext.HttpContext.Request.Headers["recaptchaToken"] = captchaToken.value;

            Member member = new Member
            {
                AccessToken = Guid.NewGuid().ToString(),
                Email = "*****@*****.**",
                ID = Guid.NewGuid(),
                Name = Guid.NewGuid().ToString(),
                PassWord = Guid.NewGuid().ToString(),
                RefreshToken = Guid.NewGuid().ToString(),
                State = StateMember.Allow,
                UserName = Guid.NewGuid().ToString()
            };

            controller.CreateMember(member);

            testELSMemberRepository.Get(member);
        }
Esempio n. 2
0
        public bool VerifyToken(string token, string text)
        {
            string       json         = cryptService.Decrypt(CypherName, token);
            CaptchaToken captchaToken = JsonConvert.DeserializeObject <CaptchaToken>(json);

            if (captchaToken.Expire < DateTime.UtcNow)
            {
                return(false);
            }

            return(string.Equals(captchaToken.Text, text));
        }
Esempio n. 3
0
        public string MakeCryptedCaptchaToken()
        {
            var token = new CaptchaToken
            {
                Text   = GenerateCaptchaText(),
                Expire = DateTime.UtcNow.Add(cacheTimeout),
                Guid   = Guid.NewGuid()
            };

            var tokenJson = JsonConvert.SerializeObject(token);

            return(cryptService.Crypt(CypherName, tokenJson));
        }
Esempio n. 4
0
        public void Solved(object sender, JSExtInvokeArgs e)
        {
            string       str  = e.Arguments[0].ToString();
            CaptchaToken item = new CaptchaToken {
                Id          = Guid.NewGuid().ToString(),
                Created     = DateTime.Now,
                CaptchaType = CaptchaSolver.CaptchaService.Manual,
                Website     = this.m_sitePath
            };

            item.Token     = str;
            item.Timestamp = DateTime.Now;
            item.Expires   = item.Timestamp.AddMinutes(2.0);
            TimeSpan span = (TimeSpan)(item.Timestamp - item.Created);

            item.SolveTime           = (span.Minutes * 60) + span.Seconds;
            this._task.ManualSolved  = true;
            this._task.CaptchaWindow = null;
            this._task = null;
            switch (this._solverSite)
            {
            case SolverSite.SHOPIFY:
                item.Platform = "Shopify";
                Global.ShopifyTokens.Add(item);
                break;

            case SolverSite.SNS:
                item.Platform = "Sneakernstuff";
                Global.SnsTokens.Add(item);
                break;

            case SolverSite.SUPREME:
                item.Platform = "Supreme";
                Global.SupremeTokens.Add(item);
                break;

            case SolverSite.MRPORTER:
                item.Platform = "MrPorter";
                Global.MrPorterTokens.Add(item);
                break;

            case SolverSite.SIVAS:
                item.Platform = "Sivas";
                Global.SivasTokens.Add(item);
                break;

            case SolverSite.HIBBETT:
                item.Platform = "Hibbett";
                Global.HibbettTokens.Add(item);
                break;

            case SolverSite.OW:
                item.Platform = "OW";
                Global.OWTokens.Add(item);
                break;

            case SolverSite.FOOTACTION:
                item.Platform = "Footaction";
                Global.FootactionTokens.Add(item);
                break;

            case SolverSite.PRIVACY:
                item.Platform = "Privacy";
                Global.PrivacyTokens.Add(item);
                break;

            case SolverSite.HOLYPOP:
                item.Platform = "Holypopstore";
                Global.HolypopTokens.Add(item);
                break;
            }
            this.IsFree = true;
            this.Change();
        }