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-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-03-11 04:58:51 +08:00
|
|
|
document.location = getInSession 'logoutURL'
|
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: =>
|
|
|
|
# done subscribing
|
|
|
|
onLoadComplete()
|
|
|
|
|
2015-03-11 04:58:51 +08:00
|
|
|
# obtain the logoutURL
|
|
|
|
a = $.ajax({dataType: 'json', url: '/bigbluebutton/api/enter'})
|
|
|
|
a.done (data) ->
|
|
|
|
setInSession("logoutURL", data.response.logoutURL)
|
|
|
|
|
|
|
|
a.fail (data, textStatus, errorThrown) ->
|
|
|
|
alert "Error: could not find the logoutURL"
|
|
|
|
setInSession("logoutURL", document.location.hostname)
|
|
|
|
|
2015-03-03 07:07:10 +08:00
|
|
|
@render('main')
|
2015-03-03 00:46:14 +08:00
|
|
|
|
|
|
|
@route "main",
|
2015-03-03 07:07:10 +08:00
|
|
|
path: "/html5client/:meeting_id/:user_id/:auth_token"
|
2015-03-03 00:46:14 +08:00
|
|
|
onBeforeAction: ->
|
2015-03-03 07:07:10 +08:00
|
|
|
meetingId = @params.meeting_id
|
|
|
|
userId = @params.user_id
|
|
|
|
authToken = @params.auth_token
|
2014-11-13 22:29:27 +08:00
|
|
|
|
2015-03-03 00:46:14 +08:00
|
|
|
# catch if any of the user's meeting data is invalid
|
|
|
|
if not authToken? or not meetingId? or not userId?
|
2015-03-11 04:58:51 +08:00
|
|
|
# if their data is invalid, redirect the user to the logout page
|
|
|
|
document.location = getInSession 'logoutURL'
|
2015-03-03 00:46:14 +08:00
|
|
|
|
|
|
|
else
|
2014-11-13 22:29:27 +08:00
|
|
|
Meteor.call("validateAuthToken", meetingId, userId, authToken)
|
2014-12-11 03:30:14 +08:00
|
|
|
|
|
|
|
applyNewSessionVars = ->
|
|
|
|
setInSession("authToken", authToken)
|
|
|
|
setInSession("meetingId", meetingId)
|
|
|
|
setInSession("userId", userId)
|
2015-03-03 07:07:10 +08:00
|
|
|
Router.go('/html5client')
|
2014-12-11 03:30:14 +08:00
|
|
|
|
2014-12-11 03:31:03 +08:00
|
|
|
clearSessionVar(applyNewSessionVars)
|
2014-11-13 22:29:27 +08:00
|
|
|
|
2015-02-14 07:27:31 +08:00
|
|
|
@next()
|