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)); }
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))); }
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")); }
// 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)); }
public async Task <IActionResult> Index() { return(View(new IndexViewModel(await _flagRepository.GetFlag("49bdf307-510b-4429-8539-a62c6a415efb")))); }
public async Task <IActionResult> Index(string team) { var flag = await _flagRepository.GetFlag("49bdf307-510b-4429-8539-a62c6a415efd"); return(View(new AdminViewModel(flag, team))); }