DEV: Raise error when anon subscribes to PresenceChannels on login_required sites

In this situation, messagebus and the server-side Presence endpoints are unavailable, so it's better to quit early in the JS
This commit is contained in:
David Taylor 2021-10-26 12:46:07 +01:00
parent d43b77b56b
commit edc1378aed

View File

@ -389,6 +389,10 @@ export default class PresenceService extends Service {
}
async _subscribe(channelProxy, initialData = null) {
if (this.siteSettings.login_required && !this.currentUser) {
throw "Presence is only available to authenticated users on login-required sites";
}
this._addSubscribed(channelProxy);
const channelName = channelProxy.name;
let state = this._presenceChannelStates[channelName];