2014-07-28 23:00:07 +08:00
|
|
|
@Router.configure layoutTemplate: 'layout'
|
2014-06-19 04:11:29 +08:00
|
|
|
|
2014-07-28 23:00:07 +08:00
|
|
|
@Router.map ->
|
2015-03-14 04:43:32 +08:00
|
|
|
# this is how we handle login attempts
|
|
|
|
@route "main",
|
|
|
|
path: "/html5client/:meeting_id/:user_id/:auth_token"
|
|
|
|
onBeforeAction: ->
|
|
|
|
meetingId = @params.meeting_id
|
|
|
|
userId = @params.user_id
|
|
|
|
authToken = @params.auth_token
|
|
|
|
|
|
|
|
# catch if any of the user's meeting data is invalid
|
|
|
|
if not authToken? or not meetingId? or not userId?
|
|
|
|
# if their data is invalid, redirect the user to the logout page
|
|
|
|
document.location = getInSession 'logoutURL'
|
|
|
|
|
|
|
|
else
|
|
|
|
Meteor.call("validateAuthToken", meetingId, userId, authToken)
|
|
|
|
|
|
|
|
applyNewSessionVars = ->
|
|
|
|
setInSession("authToken", authToken)
|
|
|
|
setInSession("meetingId", meetingId)
|
|
|
|
setInSession("userId", userId)
|
|
|
|
Router.go('/html5client')
|
|
|
|
|
|
|
|
clearSessionVar(applyNewSessionVars)
|
|
|
|
|
|
|
|
@next()
|
|
|
|
|
|
|
|
|
|
|
|
# the user successfully logged in
|
2015-03-03 07:07:10 +08:00
|
|
|
@route "signedin",
|
|
|
|
path: "/html5client"
|
|
|
|
action: ->
|
|
|
|
meetingId = getInSession "meetingId"
|
|
|
|
userId = getInSession "userId"
|
|
|
|
authToken = getInSession "authToken"
|
|
|
|
|
|
|
|
onErrorFunction = (error, result) ->
|
|
|
|
console.log "ONERRORFUNCTION"
|
|
|
|
#if error
|
|
|
|
# # Was unable to authorize the user. Redirect to the home page
|
|
|
|
# # alert error.reason
|
2015-02-14 08:14:49 +08:00
|
|
|
|
|
|
|
#make sure the user is not let through
|
|
|
|
Meteor.call("userLogout", meetingId, userId, authToken)
|
|
|
|
|
|
|
|
clearSessionVar (alert "Please sign in again")
|
2015-05-07 05:03:28 +08:00
|
|
|
document.location = getInSession('logoutURL') or '/'
|
2015-03-03 07:07:10 +08:00
|
|
|
return
|
|
|
|
|
|
|
|
Meteor.subscribe 'chat', meetingId, userId, authToken, onError: onErrorFunction, onReady: =>
|
|
|
|
Meteor.subscribe 'shapes', meetingId, onReady: =>
|
|
|
|
Meteor.subscribe 'slides', meetingId, onReady: =>
|
|
|
|
Meteor.subscribe 'meetings', meetingId, onReady: =>
|
|
|
|
Meteor.subscribe 'presentations', meetingId, onReady: =>
|
|
|
|
Meteor.subscribe 'users', meetingId, userId, authToken, onError: onErrorFunction, onReady: =>
|
2015-03-07 03:47:07 +08:00
|
|
|
Meteor.subscribe 'whiteboard-clean-status', meetingId, onReady: =>
|
2015-07-22 07:55:42 +08:00
|
|
|
Meteor.subscribe 'bbb_poll', meetingId, userId, authToken, onReady: =>
|
2015-03-07 03:47:07 +08:00
|
|
|
# done subscribing
|
|
|
|
onLoadComplete()
|
|
|
|
|
|
|
|
handleLogourUrlError = () ->
|
|
|
|
alert "Error: could not find the logoutURL"
|
|
|
|
setInSession("logoutURL", document.location.hostname)
|
2015-03-14 05:01:54 +08:00
|
|
|
return
|
2015-03-07 03:47:07 +08:00
|
|
|
|
|
|
|
# obtain the logoutURL
|
|
|
|
a = $.ajax({dataType: 'json', url: '/bigbluebutton/api/enter'})
|
|
|
|
a.done (data) ->
|
|
|
|
if data.response.logoutURL? # for a meeting with 0 users
|
|
|
|
setInSession("logoutURL", data.response.logoutURL)
|
2015-03-14 05:01:54 +08:00
|
|
|
return
|
|
|
|
else
|
2015-03-07 03:47:07 +08:00
|
|
|
if data.response.logoutUrl? # for a running meeting
|
|
|
|
setInSession("logoutURL", data.response.logoutUrl)
|
|
|
|
return
|
|
|
|
else
|
|
|
|
handleLogourUrlError()
|
|
|
|
|
|
|
|
a.fail (data, textStatus, errorThrown) ->
|
|
|
|
handleLogourUrlError()
|
2015-03-11 04:58:51 +08:00
|
|
|
|
2015-03-03 07:07:10 +08:00
|
|
|
@render('main')
|
2015-03-03 00:46:14 +08:00
|
|
|
|
2014-12-11 03:30:14 +08:00
|
|
|
|
2015-03-14 04:43:32 +08:00
|
|
|
# endpoint - is the html5client running (ready to handle a user)
|
|
|
|
@route 'meteorEndpoint',
|
|
|
|
path: '/check'
|
|
|
|
where: 'server'
|
|
|
|
action: ->
|
|
|
|
@response.writeHead 200, 'Content-Type': 'application/json'
|
2014-11-13 22:29:27 +08:00
|
|
|
|
2015-03-14 04:43:32 +08:00
|
|
|
# reply that the html5client is running
|
|
|
|
@response.end JSON.stringify {"html5clientStatus":"running"}
|
|
|
|
return
|
|
|
|
return
|