public PlayerConnection(LoginDto loginDto, IPlayerCommandFactory playerCommandFactory, IPlayerRepository playerRepository, IGame game) { _playerCommandFactory = playerCommandFactory; _playerRepository = playerRepository; _game = game; _loginDto = loginDto; _dataToSend = new BufferBlock<string>(); }
private bool TryAuthorize(LoginDto loginDto) { if (loginDto.IsAdmin) { return loginDto.Login == _adminCredentials.AdminLogin && loginDto.Password == _adminCredentials.AdminPassword; } var player = _playerRepository.Players.FirstOrDefault(x => x.Name == loginDto.Login); if (player == null) { return true; } return player.Password == loginDto.Password; }
private void SendLoginData(TextReader reader, TextWriter writer, string userName, string password) { var loginDto = new LoginDto { Login = userName, Password = password, IsAdmin = true }; var loginJson = loginDto.ToJson(); writer.WriteLine(loginJson); reader.ReadLine(); }