bigbluebutton-Github/bigbluebutton-html5/app/lib/router.coffee

68 lines
2.4 KiB
CoffeeScript
Raw Normal View History

2014-07-28 23:00:07 +08:00
@Router.configure layoutTemplate: 'layout'
2014-07-28 23:00:07 +08:00
@Router.map ->
@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
#make sure the user is not let through
Meteor.call("userLogout", meetingId, userId, authToken)
clearSessionVar (alert "Please sign in again")
document.location = getInSession 'logoutURL'
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()
# 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)
@render('main')
2015-03-03 00:46:14 +08:00
@route "main",
path: "/html5client/:meeting_id/:user_id/:auth_token"
2015-03-03 00:46:14 +08:00
onBeforeAction: ->
meetingId = @params.meeting_id
userId = @params.user_id
authToken = @params.auth_token
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?
# 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
Meteor.call("validateAuthToken", meetingId, userId, authToken)
applyNewSessionVars = ->
setInSession("authToken", authToken)
setInSession("meetingId", meetingId)
setInSession("userId", userId)
Router.go('/html5client')
clearSessionVar(applyNewSessionVars)
@next()