redoing the router with authToken
This commit is contained in:
parent
93f2338dae
commit
a003365d35
@ -1,5 +1,3 @@
|
||||
# Todo
|
||||
# When a user is to be kicked remove their authorization token from servers
|
||||
|
||||
@Router.configure layoutTemplate: 'layout'
|
||||
|
||||
@ -14,50 +12,36 @@
|
||||
if meetingId? and userId? and authToken?
|
||||
Meteor.call("validateAuthToken", meetingId, userId, authToken)
|
||||
setInSession("authToken", authToken)
|
||||
setInSession("meetingId", meetingId)
|
||||
setInSession("userId", userId)
|
||||
|
||||
if Meteor.isClient #TODO try to get rid of this
|
||||
sendMeetingInfoToClient(meetingId, userId) #TODO try to get rid of this
|
||||
|
||||
Meteor.subscribe 'users', meetingId, userId, authToken, ->
|
||||
console.log "now I have access to the users from the client. my userid is #{userId}"
|
||||
|
||||
Meteor.call "getMyInfo", meetingId, 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)
|
||||
setInSession("userSecret", result.userSecret)
|
||||
me = Meteor.Users.findOne({_id:result.DBID})
|
||||
console.log "me=" + JSON.stringify me
|
||||
if me?
|
||||
Router.go('/') #we are sure the user has dbid, userid and exists in the collection
|
||||
else
|
||||
alert "did not find the user in the collection"
|
||||
console.log "now I have access to the users from the client. my userid is #{userId} _#{Meteor.Users.find().count()}__"
|
||||
Meteor.subscribe 'chat', meetingId, userId, authToken, ->
|
||||
console.log "ready"
|
||||
Router.go('/')
|
||||
|
||||
@route "main",
|
||||
path: "/"
|
||||
onBeforeAction: ->
|
||||
meetingId = getInSession('meetingId')
|
||||
userId = getInSession("userId")
|
||||
console.log "on /: meetingId=#{meetingId} userId=#{userId} DBID=#{getInSession('DBID')}"
|
||||
Meteor.subscribe 'chat', meetingId, userId, getInSession 'authToken', ->
|
||||
console.log "in main. onBeforeAction"
|
||||
authToken = getInSession 'authToken'
|
||||
meetingId = getInSession 'meetingId'
|
||||
userId = getInSession 'userId'
|
||||
Meteor.subscribe 'chat', meetingId, userId, authToken, ->
|
||||
Meteor.subscribe 'shapes', meetingId, ->
|
||||
Meteor.subscribe 'slides', meetingId, ->
|
||||
Meteor.subscribe 'meetings', meetingId, ->
|
||||
Meteor.subscribe 'presentations', meetingId, ->
|
||||
Meteor.subscribe 'users', meetingId, userId, getInSession 'authToken'
|
||||
Meteor.subscribe 'users', meetingId, userId, authToken, ->
|
||||
console.log "done subscribing"
|
||||
@render('main')
|
||||
|
||||
Meteor.call "getMyInfo", meetingId, userId, (error, result) ->
|
||||
unless result.error?
|
||||
console.log "on /, this is my info #{JSON.stringify result}"
|
||||
setInSession("DBID", result.DBID)
|
||||
setInSession("userName", result.name)
|
||||
#setInSession("userSecret", result.userSecret)
|
||||
|
||||
@next() #TODO maybe we need to wait for the other 2 things above to be complete
|
||||
action: ->
|
||||
console.log "main. action"
|
||||
|
||||
@route "logout",
|
||||
path: "logout"
|
||||
|
@ -1,9 +1,10 @@
|
||||
# Publish only the users that are in the particular meetingId
|
||||
# On the client side we pass the meetingId parameter
|
||||
Meteor.publish 'users', (meetingId, userid, authToken) ->
|
||||
console.log "attempt publishing users for #{meetingId}, #{userid}, #{authToken}"
|
||||
if isAllowedTo('subscribeUsers', meetingId, userid, authToken)
|
||||
|
||||
console.log "publishing users for #{meetingId}, #{userid}"
|
||||
console.log "publishing users for #{meetingId}, #{userid}, #{authToken}"
|
||||
###
|
||||
u = Meteor.Users.findOne({'userId': userid, 'meetingId': meetingId})
|
||||
if u?
|
||||
@ -49,15 +50,19 @@ Meteor.publish 'users', (meetingId, userid, authToken) ->
|
||||
|
||||
Meteor.publish 'chat', (meetingId, userid, authToken) ->
|
||||
if isAllowedTo('subscribeChat', meetingId, userid, authToken)
|
||||
console.log "publishing chat for #{meetingId} #{userid}"
|
||||
console.log "publishing chat for #{meetingId} #{userid} #{authToken}"
|
||||
me = Meteor.Users.findOne({meetingId: meetingId, userId: userid})
|
||||
if me?
|
||||
me = me._id
|
||||
Meteor.Chat.find({$or: [
|
||||
console.log "me = #{me}"
|
||||
#TODO change _id with userid
|
||||
return Meteor.Chat.find({$or: [
|
||||
{'message.chat_type': 'PUBLIC_CHAT', 'meetingId': meetingId},
|
||||
{'message.from_userid': me, 'meetingId': meetingId},
|
||||
{'message.to_userid': me, 'meetingId': meetingId}
|
||||
]})
|
||||
else
|
||||
console.log "could not find myself in publishing chat"
|
||||
|
||||
Meteor.publish 'shapes', (meetingId) ->
|
||||
Meteor.Shapes.find({meetingId: meetingId})
|
||||
|
Loading…
Reference in New Issue
Block a user