From d19c127b1fa3d81f7811818e7a7eadc1fea5472f Mon Sep 17 00:00:00 2001 From: Oswaldo Acauan Date: Wed, 13 Dec 2017 15:58:56 -0200 Subject: [PATCH] Add redirect to /logout if not loggedin or on subscription errors --- .../imports/startup/client/base.jsx | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/bigbluebutton-html5/imports/startup/client/base.jsx b/bigbluebutton-html5/imports/startup/client/base.jsx index d825b5dc70..1967e0580d 100644 --- a/bigbluebutton-html5/imports/startup/client/base.jsx +++ b/bigbluebutton-html5/imports/startup/client/base.jsx @@ -1,5 +1,6 @@ import React, { Component } from 'react'; import { createContainer } from 'meteor/react-meteor-data'; +import { withRouter } from 'react-router'; import PropTypes from 'prop-types'; import Auth from '/imports/ui/services/auth'; import AppContainer from '/imports/ui/components/app/container'; @@ -86,22 +87,29 @@ const SUBSCRIPTIONS_NAME = [ 'slides', 'captions', 'breakouts', 'voiceUsers', 'whiteboard-multi-user', ]; -const BaseContainer = createContainer(({ params }) => { +const BaseContainer = withRouter(createContainer(({ params, router }) => { if (params.errorCode) return params; if (!Auth.loggedIn) { - return { - errorCode: 401, - error: 'You are unauthorized to access this meeting', - }; + return router.push('/logout'); } - const credentials = Auth.credentials; - const subscriptionsHandlers = SUBSCRIPTIONS_NAME.map(name => Meteor.subscribe(name, credentials)); + const { credentials } = Auth; + + const subscriptionErrorHandler = { + onError: (error) => { + console.error(error); + return router.push('/logout'); + }, + }; + + const subscriptionsHandlers = SUBSCRIPTIONS_NAME.map(name => + Meteor.subscribe(name, credentials, subscriptionErrorHandler)); + return { locale: Settings.application.locale, subscriptionsReady: subscriptionsHandlers.every(handler => handler.ready()), }; -}, Base); +}, Base)); export default BaseContainer;