Exemplo n.º 1
0
        private Flag GetRandomFlag(FlagRepository repository)
        {
            Random r = new Random();

            int opt = r.Next(1, 10);

            while (opt == this.Id)
            {
                opt = r.Next(1, 10);
            }

            return(repository.GetFlag(opt));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Index()
        {
            var flag = "";

            if (Request.Cookies["jar"] == "admin=true")
            {
                flag = await _flagRepository.GetFlag("bec30cd6-315e-42a0-a450-a3fc61a0a0f6");
            }
            Response.Cookies.Append("jar", "admin=false", new Microsoft.AspNetCore.Http.CookieOptions
            {
                SameSite = Microsoft.AspNetCore.Http.SameSiteMode.Strict,
                MaxAge   = TimeSpan.FromMinutes(2),
            });
            return(View(new ViewModel(flag)));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Index(
            SubmitFlagViewModel model,
            [FromServices] FlagRepository _flagRepository,
            [FromServices] ScoringRepository _scoreRepository
            )
        {
            if (ModelState.IsValid)
            {
                var quest = await _questRepository.GetQuest(model.QuestId);

                if (quest != null)
                {
                    var flag = await _flagRepository.GetFlag(quest);

                    if (CryptographicOperations.FixedTimeEquals(Encoding.Unicode.GetBytes(flag), Encoding.Unicode.GetBytes(model.Flag)))
                    {
                        await _scoreRepository.AddTeamScore(User.Identity.Name !, quest.Id);

                        return(RedirectToAction("Index", "Scoreboard"));
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 4
0
        // GET: Flags
        public JsonResult Flag(int id)
        {
            Question question = new Question(_Repository.GetFlag(id), _Repository);

            return(Json(new { Id = question.Id, Options = question.Options }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
 public async Task <IActionResult> Index()
 {
     return(View(new IndexViewModel(await _flagRepository.GetFlag("49bdf307-510b-4429-8539-a62c6a415efb"))));
 }
Exemplo n.º 6
0
        public async Task <IActionResult> Index(string team)
        {
            var flag = await _flagRepository.GetFlag("49bdf307-510b-4429-8539-a62c6a415efd");

            return(View(new AdminViewModel(flag, team)));
        }