Skip to content

Commit c6777c0

Browse files
committed
Fix missing check if username is provided for create
1 parent fe97a38 commit c6777c0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

templates/new/client/ts/game.ts.tmpl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,12 @@ export class Game {
143143

144144
switch (operation) {
145145
case 'create':
146-
const { game, gameId, joinSecret } = await this.createAndJoin(username, _public, _protected, config, verbosityOverride || verbosity);
147-
logGameCreds(gameId, joinSecret);
148-
return { game, gameId, joinSecret };
146+
if (username) {
147+
const { game, gameId, joinSecret } = await this.createAndJoin(username, _public, _protected, config, verbosityOverride || verbosity);
148+
logGameCreds(gameId, joinSecret);
149+
return { game, gameId, joinSecret };
150+
}
151+
throw `"op=create" requires the "username" query parameter.`;
149152
case 'join':
150153
if (gameId && username) return await this.join(gameId, username, joinSecret || undefined, verbosityOverride || verbosity);
151154
throw `"op=join" requires the "game_id" and "username" query parameters.`;

0 commit comments

Comments
 (0)