2016-01-13 04:15:16 +08:00
|
|
|
this.Router.configure({
|
|
|
|
layoutTemplate: 'layout'
|
|
|
|
});
|
|
|
|
|
|
|
|
this.Router.map(function() {
|
2016-01-15 13:46:41 +08:00
|
|
|
// this is how we handle login attempts
|
2016-01-13 04:15:16 +08:00
|
|
|
this.route("main", {
|
|
|
|
path: "/html5client/:meeting_id/:user_id/:auth_token",
|
|
|
|
where: "client",
|
|
|
|
onBeforeAction() {
|
|
|
|
let applyNewSessionVars, authToken, meetingId, userId;
|
|
|
|
meetingId = this.params.meeting_id;
|
|
|
|
userId = this.params.user_id;
|
|
|
|
authToken = this.params.auth_token;
|
|
|
|
setInSession("loginUrl", this.originalUrl);
|
2016-01-15 13:46:41 +08:00
|
|
|
|
|
|
|
// catch if any of the user's meeting data is invalid
|
2016-01-13 04:15:16 +08:00
|
|
|
if ((authToken == null) || (meetingId == null) || (userId == null)) {
|
2016-01-15 13:46:41 +08:00
|
|
|
// if their data is invalid, redirect the user to the logout page
|
2016-01-13 04:15:16 +08:00
|
|
|
document.location = getInSession('logoutURL');
|
|
|
|
} else {
|
|
|
|
Meteor.call("validateAuthToken", meetingId, userId, authToken);
|
|
|
|
applyNewSessionVars = function() {
|
|
|
|
setInSession("authToken", authToken);
|
|
|
|
setInSession("meetingId", meetingId);
|
|
|
|
setInSession("userId", userId);
|
|
|
|
return Router.go('/html5client');
|
|
|
|
};
|
|
|
|
clearSessionVar(applyNewSessionVars);
|
|
|
|
}
|
|
|
|
return this.next();
|
|
|
|
}
|
|
|
|
});
|
2016-01-15 13:46:41 +08:00
|
|
|
|
|
|
|
// the user successfully logged in
|
2016-01-13 04:15:16 +08:00
|
|
|
this.route("signedin", {
|
|
|
|
path: "/html5client",
|
|
|
|
where: "client",
|
|
|
|
action() {
|
|
|
|
let authToken, meetingId, onErrorFunction, userId;
|
|
|
|
meetingId = getInSession("meetingId");
|
|
|
|
userId = getInSession("userId");
|
|
|
|
authToken = getInSession("authToken");
|
|
|
|
onErrorFunction = function(error, result) {
|
|
|
|
console.log("ONERRORFUNCTION");
|
2016-01-15 13:46:41 +08:00
|
|
|
|
|
|
|
//make sure the user is not let through
|
2016-01-13 04:15:16 +08:00
|
|
|
Meteor.call("userLogout", meetingId, userId, authToken);
|
2016-01-15 13:46:41 +08:00
|
|
|
|
2016-01-13 04:15:16 +08:00
|
|
|
clearSessionVar();
|
2016-01-15 13:46:41 +08:00
|
|
|
|
|
|
|
// Attempt to log back in
|
2016-01-13 04:15:16 +08:00
|
|
|
if (error == null) {
|
|
|
|
window.location.href = getInSession('loginUrl') || getInSession('logoutURL');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
Meteor.subscribe('chat', meetingId, userId, authToken, {
|
|
|
|
onError: onErrorFunction,
|
|
|
|
onReady: (_this => {
|
|
|
|
return function() {
|
|
|
|
return Meteor.subscribe('shapes', meetingId, {
|
|
|
|
onReady: function() {
|
|
|
|
return Meteor.subscribe('slides', meetingId, {
|
|
|
|
onReady: function() {
|
|
|
|
return Meteor.subscribe('meetings', meetingId, {
|
|
|
|
onReady: function() {
|
|
|
|
return Meteor.subscribe('presentations', meetingId, {
|
|
|
|
onReady: function() {
|
|
|
|
return Meteor.subscribe('users', meetingId, userId, authToken, {
|
|
|
|
onError: onErrorFunction,
|
|
|
|
onReady: function() {
|
|
|
|
return Meteor.subscribe('whiteboard-clean-status', meetingId, {
|
|
|
|
onReady: function() {
|
|
|
|
return Meteor.subscribe('bbb_poll', meetingId, userId, authToken, {
|
|
|
|
onReady: function() {
|
|
|
|
return Meteor.subscribe('bbb_cursor', meetingId, {
|
|
|
|
onReady: function() {
|
|
|
|
let a, handleLogourUrlError;
|
2016-01-15 13:46:41 +08:00
|
|
|
// done subscribing, start rendering the client and set default settings
|
2016-01-13 04:15:16 +08:00
|
|
|
_this.render('main');
|
|
|
|
onLoadComplete();
|
|
|
|
handleLogourUrlError = function() {
|
|
|
|
alert("Error: could not find the logoutURL");
|
|
|
|
setInSession("logoutURL", document.location.hostname);
|
|
|
|
};
|
2016-01-15 13:46:41 +08:00
|
|
|
|
|
|
|
// obtain the logoutURL
|
2016-01-13 04:15:16 +08:00
|
|
|
a = $.ajax({
|
|
|
|
dataType: 'json',
|
|
|
|
url: '/bigbluebutton/api/enter'
|
|
|
|
});
|
|
|
|
a.done(data => {
|
2016-01-15 13:46:41 +08:00
|
|
|
if (data.response.logoutURL != null) { // for a meeting with 0 users
|
2016-01-13 04:15:16 +08:00
|
|
|
setInSession("logoutURL", data.response.logoutURL);
|
|
|
|
} else {
|
2016-01-15 13:46:41 +08:00
|
|
|
if (data.response.logoutUrl != null) { // for a running meeting
|
2016-01-13 04:15:16 +08:00
|
|
|
setInSession("logoutURL", data.response.logoutUrl);
|
|
|
|
} else {
|
|
|
|
return handleLogourUrlError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return a.fail((data, textStatus, errorThrown) => {
|
|
|
|
return handleLogourUrlError();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
})(this)
|
|
|
|
});
|
|
|
|
return this.render('loading');
|
|
|
|
}
|
|
|
|
});
|
2016-01-15 13:46:41 +08:00
|
|
|
|
|
|
|
// endpoint - is the html5client running (ready to handle a user)
|
2016-01-13 04:15:16 +08:00
|
|
|
this.route('meteorEndpoint', {
|
|
|
|
path: '/check',
|
|
|
|
where: 'server',
|
|
|
|
action() {
|
|
|
|
this.response.writeHead(200, {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
});
|
2016-01-15 13:46:41 +08:00
|
|
|
|
|
|
|
// reply that the html5client is running
|
2016-01-13 04:15:16 +08:00
|
|
|
this.response.end(JSON.stringify({
|
|
|
|
"html5clientStatus": "running"
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|