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 ->
|
2014-06-19 04:11:29 +08:00
|
|
|
@route "login",
|
2014-11-13 21:46:39 +08:00
|
|
|
path: "/login"
|
|
|
|
action: ->
|
2014-11-13 22:29:27 +08:00
|
|
|
meetingId = @params.query.meeting_id
|
|
|
|
userId = @params.query.user_id
|
|
|
|
authToken = @params.query.auth_token
|
|
|
|
|
|
|
|
if meetingId? and userId? and authToken?
|
|
|
|
Meteor.call("validateAuthToken", meetingId, userId, authToken)
|
2014-12-11 03:30:14 +08:00
|
|
|
|
|
|
|
applyNewSessionVars = ->
|
|
|
|
setInSession("authToken", authToken)
|
|
|
|
setInSession("meetingId", meetingId)
|
|
|
|
setInSession("userId", userId)
|
2014-12-12 01:23:19 +08:00
|
|
|
Router.go('/')
|
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
|
|
|
|
2014-06-19 04:11:29 +08:00
|
|
|
@route "main",
|
|
|
|
path: "/"
|
2014-11-11 20:18:07 +08:00
|
|
|
onBeforeAction: ->
|
2014-11-22 01:07:16 +08:00
|
|
|
authToken = getInSession 'authToken'
|
|
|
|
meetingId = getInSession 'meetingId'
|
|
|
|
userId = getInSession 'userId'
|
2015-01-17 01:00:37 +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 url
|
|
|
|
# logout url is the server ip address at port 4000, bringing the user back
|
|
|
|
# to the login page
|
|
|
|
document.location = Meteor.config.app.logOutUrl
|
|
|
|
|
2015-02-06 03:58:39 +08:00
|
|
|
onErrorFunction = (error, result) ->
|
|
|
|
if error
|
|
|
|
# Was unable to authorize the user. Redirect to the home page
|
|
|
|
# alert error.reason
|
2015-02-07 00:55:46 +08:00
|
|
|
clearSessionVar alert "Please sign in again"
|
2015-02-06 03:58:39 +08:00
|
|
|
document.location = Meteor.config.app.logOutUrl
|
|
|
|
return
|
|
|
|
|
2015-02-07 03:41:18 +08:00
|
|
|
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-02-06 03:58:39 +08:00
|
|
|
# done subscribing
|
2014-12-11 04:09:17 +08:00
|
|
|
onLoadComplete()
|
2015-02-07 03:41:18 +08:00
|
|
|
@render('main')
|
2015-02-14 07:27:31 +08:00
|
|
|
@next()
|