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-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",
|
|
|
|
path: "/meeting_id=*"
|
|
|
|
action: () ->
|
2014-07-25 04:06:07 +08:00
|
|
|
self = @
|
2014-10-25 02:02:01 +08:00
|
|
|
|
2014-10-30 03:39:13 +08:00
|
|
|
url = location.href
|
2014-06-19 04:11:29 +08:00
|
|
|
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
|
2014-06-19 04:11:29 +08:00
|
|
|
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]
|
2014-06-19 04:11:29 +08:00
|
|
|
|
2014-07-04 04:50:24 +08:00
|
|
|
if meetingId? and userId? and authToken?
|
2014-08-08 21:09:39 +08:00
|
|
|
Meteor.call("validateAuthToken", meetingId, userId, authToken)
|
2014-10-31 23:25:32 +08:00
|
|
|
if Meteor.isClient then sendMeetingInfoToClient(meetingId, userId)
|
2014-11-12 03:54:28 +08:00
|
|
|
Meteor.subscribe 'users', meetingId, userId, ->
|
|
|
|
console.log "now I have access to the users from the client. my userid is #{userId}"
|
|
|
|
|
|
|
|
Meteor.call "getMyInfo", userId, (error, result) ->
|
|
|
|
if result.error?
|
|
|
|
alert result.error
|
|
|
|
# redirect towards a different page
|
|
|
|
else
|
|
|
|
console.log "onBeforeAction2"
|
|
|
|
setInSession("DBID", result.DBID)
|
|
|
|
setInSession("userName", result.name)
|
|
|
|
me = Meteor.Users.findOne({_id:result.DBID})
|
|
|
|
console.log "me=" + JSON.stringify me
|
2014-11-12 20:53:36 +08:00
|
|
|
if me?
|
|
|
|
self.redirect('/') #we are sure the user has dbid, userid and exists in the collection
|
|
|
|
else
|
|
|
|
alert "did not find the user in the collection"
|
2014-10-30 03:39:13 +08:00
|
|
|
else
|
2014-07-04 04:50:24 +08:00
|
|
|
console.log "unable to extract from the URL some of {meetingId, userId, authToken}"
|
2014-10-25 02:02:01 +08:00
|
|
|
|
2014-06-19 04:11:29 +08:00
|
|
|
@route "main",
|
|
|
|
path: "/"
|
2014-11-11 20:18:07 +08:00
|
|
|
onBeforeAction: ->
|
|
|
|
meetingId = getInSession('meetingId')
|
|
|
|
userId = getInSession("userId")
|
2014-11-12 20:53:36 +08:00
|
|
|
console.log "on /: meetingId=#{meetingId} userId=#{userId} DBID=#{getInSession('DBID')}"
|
2014-11-12 21:15:13 +08:00
|
|
|
Meteor.subscribe 'chat', meetingId, userId, ->
|
|
|
|
Meteor.subscribe 'shapes', meetingId, ->
|
|
|
|
Meteor.subscribe 'slides', meetingId, ->
|
|
|
|
Meteor.subscribe 'meetings', meetingId, ->
|
|
|
|
Meteor.subscribe 'presentations', meetingId, ->
|
|
|
|
Meteor.subscribe 'users', meetingId, userId
|
2014-06-27 23:37:33 +08:00
|
|
|
|
2014-11-12 20:53:36 +08:00
|
|
|
Meteor.call "getMyInfo", userId, (error, result) ->
|
|
|
|
unless result.error?
|
|
|
|
console.log "on /, this is my info #{JSON.stringify result}"
|
|
|
|
setInSession("DBID", result.DBID)
|
|
|
|
setInSession("userName", result.name)
|
|
|
|
|
2014-06-24 03:11:57 +08:00
|
|
|
@route "logout",
|
|
|
|
path: "logout"
|