@colyseus/core 0.18.12 → 0.18.14

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.mjs CHANGED
@@ -1097,12 +1097,15 @@ var Room = class _Room {
1097
1097
  try {
1098
1098
  if (authData) {
1099
1099
  client.auth = authData;
1100
- } else if (this.onAuth !== _Room.prototype.onAuth) {
1100
+ }
1101
+ const authedStatically = authData && this.constructor.onAuth !== _Room.onAuth;
1102
+ if (!authedStatically && this.onAuth !== _Room.prototype.onAuth) {
1101
1103
  try {
1102
- client.auth = await this.onAuth(client, joinOptions, authContext);
1103
- if (!client.auth) {
1104
+ const result = await this.onAuth(client, joinOptions, authContext);
1105
+ if (!result) {
1104
1106
  throw new ServerError(ErrorCode.AUTH_FAILED, "onAuth failed");
1105
1107
  }
1108
+ client.auth = result === true && authData || result;
1106
1109
  } catch (e) {
1107
1110
  delete this._reservedSeats[sessionId];
1108
1111
  await this.#_decrementClientCount();