public GameSessionSaver(LifeGameDBContext context, IServiceProvider serviceProvider, SessionsRepo sessionsRepo, GameObjectsSessionTypesRepo gameObjectsSessionTypesRepo, SessionTypesMoveTypesRepo sessionTypesMoveTypesRepo, SessionPartiallyEatableTypesRepo sessionPartiallyEatableTypesRepo) : base(context) { _serviceProvider = serviceProvider; _sessionsRepo = sessionsRepo; _gameObjectsSessionTypesRepo = gameObjectsSessionTypesRepo; _sessionTypesMoveTypesRepo = sessionTypesMoveTypesRepo; _sessionPartiallyEatableTypesRepo = sessionPartiallyEatableTypesRepo; }
private void SetCookies(bool userPresent, string username) { if (userPresent) { var edded = SessionsRepo.AddSession(username); var cookie = new Cookie("SESS_ID", edded.Item1, "/", "api.sharkbank.ru"); cookie.Expires = edded.Item2; currentResponse.AppendHeader("X-CSRF-Token", edded.Item3); currentResponse.SetCookie(cookie); currentResponse.StatusCode = 200; } else { currentResponse.StatusCode = 401; } }
private Result <None> PermitAcces(Cookie cookie) { if (cookie.Expired) { return(Result.Fail <None>("Cookie expired")); } if (cookie.Name != "SESS_ID" || cookie.Value.Split("|").Length != 2) { return(Result.Fail <None>("Cookie is not from this domain")); } var splittedCookies = cookie.Value.Split("|"); currentSession = splittedCookies[0]; var signature = splittedCookies[1]; if (SessionsRepo.CheckCookieSignature(currentSession, signature)) { return(Result.Ok()); } return(Result.Fail <None>("Cookie either expired either modified")); }
public LoginsController(SessionsRepo aSessionsRepo) { mSessionsRepo = aSessionsRepo; }
private bool CheckCsrf() { var token = currentRequest.Headers.GetValues("X-Csrf-Token"); return(accesPermitted && token != null && SessionsRepo.CheckFormToken(currentSession, token[0])); }
public GroupsController(GroupsRepo aGroupsRepo, SessionsRepo aSessionsRepo) { mGroupsRepo = aGroupsRepo; mSessionsRepo = aSessionsRepo; }
public HomeController(ILogger <HomeController> logger, SessionsRepo sessionsRepo) { _logger = logger; _sessionsRepo = sessionsRepo; }
public ParticipantsController(ParticipantsRepo aParticipantsRepo, SessionsRepo aSessionsRepo, GroupsRepo aGroupsRepo) { mParticipantsRepo = aParticipantsRepo; mSessionsRepo = aSessionsRepo; mGroupsRepo = aGroupsRepo; }