bigbluebutton-Github/labs/meteor-client/app/lib/router.coffee

47 lines
1.9 KiB
CoffeeScript
Raw Normal View History

2014-07-26 00:36:31 +08:00
# Todo
# When a user is to be kicked remove their authorization token from servers
2014-07-28 23:00:07 +08:00
@Router.configure layoutTemplate: 'layout'
2014-07-28 23:00:07 +08:00
@Router.map ->
@route "login",
path: "/meeting_id=*"
action: () ->
self = @
2014-10-30 03:39:13 +08:00
url = location.href
console.log "\n\nurl=#{url}\n\n"
2014-06-19 05:20:32 +08:00
#extract the meeting_id, user_id, auth_token, etc from the uri
if url.indexOf("meeting_id") > -1 # if the URL is /meeting_id=...&...
2014-10-30 03:39:13 +08:00
urlParts = url.split("&")
meetingId = urlParts[0]?.split("=")[1]
userId = urlParts[1]?.split("=")[1]
authToken = urlParts[2]?.split("=")[1]
if meetingId? and userId? and authToken?
Meteor.call("validateAuthToken", meetingId, userId, authToken)
if Meteor.isClient then sendMeetingInfoToClient(meetingId, userId)
self.redirect('/')
2014-10-30 03:39:13 +08:00
else
console.log "unable to extract from the URL some of {meetingId, userId, authToken}"
else
console.log "unable to extract the required information for the meeting from the URL"
@route "main",
path: "/"
onBeforeAction: ->
meetingId = getInSession('meetingId')
userId = getInSession("userId")
console.log "on /: meetingId=#{meetingId} userId=#{userId}"
Meteor.subscribe 'users', meetingId, userId, -> # callback for after users have been loaded on client
Meteor.subscribe 'chat', meetingId, userId, ->
Meteor.subscribe 'shapes', meetingId, ->
Meteor.subscribe 'slides', meetingId, ->
Meteor.subscribe 'meetings', meetingId, ->
Meteor.subscribe 'presentations', meetingId, ->
Meteor.call "getMyInfo", userId, (error, result) ->
#console.log "managed to reconnect successfully"
setInSession("DBID", result.DBID)
setInSession("userName", result.name)
2014-06-24 03:11:57 +08:00
@route "logout",
path: "logout"