<commit_before>Meteor.methods({
	"createGame": function(gameName, lobbyName, password) {
		if(!GAME_DEFINITIONS.hasOwnProperty(gameName)) {
			throw new Meteor.Error("unrecognized-game", "A game of the specified type is not defined.");
		}
		if(Games.findOne({"lobbyData.lobbyName": lobbyName})) {
			throw new Meteor.Error("lobby-name-taken", "A lobby with this name already exists.");
		}
		var game = {
			"gameName": gameName,
			"inGame": false,
			"lobbyData": {
				"private": false,
				"lobbyName": lobbyName,
				"players": [this.userId],
				"minPlayers": GAME_DEFINITIONS[gameName].minPlayers,
				"maxPlayers": GAME_DEFINITIONS[gameName].maxPlayers
			},
			"gameData": GAME_DEFINITIONS[gameName].gameData
		};
		if(password) {
			game.lobbyData.private = true;
			game.password = password;
		}

		Games.insert(game);
		Roles.addUsersToRoles(this.userId, ["player", "owner"], lobbyName);
	},
	"joinLobby": function(lobbyName, password) {
		var game = Games.findOne({"lobbyData.lobbyName": lobbyName});
		if(!game) {
			throw new Meteor.Error(404, "Lobby not found.");
		}
		if(game.private && game.password !== password) {
			throw new Meteor.Error(401, "Incorrect password for lobby.");
		}

		Roles.addUsersToRoles(this.userId, ["player"], lobbyName);
	}
});<commit_msg>Fix joinLobby method<commit_after>Meteor.methods({
	"createGame": function(gameName, lobbyName, password) {
		if(!GAME_DEFINITIONS.hasOwnProperty(gameName)) {
			throw new Meteor.Error("unrecognized-game", "A game of the specified type is not defined.");
		}
		if(Games.findOne({"lobbyData.lobbyName": lobbyName})) {
			throw new Meteor.Error("lobby-name-taken", "A lobby with this name already exists.");
		}
		var game = {
			"gameName": gameName,
			"inGame": false,
			"lobbyData": {
				"private": false,
				"lobbyName": lobbyName,
				"players": [this.userId],
				"minPlayers": GAME_DEFINITIONS[gameName].minPlayers,
				"maxPlayers": GAME_DEFINITIONS[gameName].maxPlayers
			},
			"gameData": GAME_DEFINITIONS[gameName].gameData
		};
		if(password) {
			game.lobbyData.private = true;
			game.password = password;
		}

		Games.insert(game);
		Roles.addUsersToRoles(this.userId, ["player", "owner"], lobbyName);
	},
	"joinLobby": function(lobbyName, password) {
		var game = Games.findOne({"lobbyData.lobbyName": lobbyName});
		if(!game) {
			throw new Meteor.Error(404, "Lobby not found.");
		}
		if(game.lobbyData.private && game.password !== password) {
			throw new Meteor.Error(401, "Incorrect password for lobby.");
		}

		Roles.addUsersToRoles(this.userId, ["player"], lobbyName);
	}
});
{'fraction_non_alphanumeric': 0.15964437572477774, 'fraction_numerical': 0.004638577502899111, 'mean_word_length': 4.52991452991453, 'pattern_counts': {'":': 26, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2834556', 'n_tokens_mistral': 1037, 'n_tokens_neox': 896, 'n_words': 174}