@colyseus/core 0.18.12 → 0.18.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/Room.cjs CHANGED
@@ -1126,12 +1126,15 @@ var Room = class _Room {
1126
1126
  try {
1127
1127
  if (authData) {
1128
1128
  client.auth = authData;
1129
- } else if (this.onAuth !== _Room.prototype.onAuth) {
1129
+ }
1130
+ const authedStatically = authData && this.constructor.onAuth !== _Room.onAuth;
1131
+ if (!authedStatically && this.onAuth !== _Room.prototype.onAuth) {
1130
1132
  try {
1131
- client.auth = await this.onAuth(client, joinOptions, authContext);
1132
- if (!client.auth) {
1133
+ const result = await this.onAuth(client, joinOptions, authContext);
1134
+ if (!result) {
1133
1135
  throw new import_ServerError.ServerError(import_shared_types.ErrorCode.AUTH_FAILED, "onAuth failed");
1134
1136
  }
1137
+ client.auth = result === true && authData || result;
1135
1138
  } catch (e) {
1136
1139
  delete this._reservedSeats[sessionId];
1137
1140
  await this.#_decrementClientCount();