Merge pull request #560 from antobinary/ip-independent-logouturl

html5client: LogoutURL reuse
This commit is contained in:
Fred Dixon 2015-03-12 16:16:22 -04:00
commit a77f741daf
4 changed files with 17 additions and 23 deletions

View File

@ -297,8 +297,8 @@ Handlebars.registerHelper "visibility", (section) ->
# the user's userId
@userLogout = (meeting, user) ->
Meteor.call("userLogout", meeting, user, getInSession("authToken"))
console.log "logging out #{Meteor.config.app.logOutUrl}"
clearSessionVar(document.location = Meteor.config.app.logOutUrl) # navigate to logout
console.log "logging out"
clearSessionVar(document.location = getInSession 'logoutURL') # navigate to logout
# Clear the local user session
@clearSessionVar = (callback) ->
@ -312,6 +312,7 @@ Handlebars.registerHelper "visibility", (section) ->
amplify.store('display_usersList', null)
amplify.store('display_whiteboard', null)
amplify.store('inChatWith', null)
amplify.store('logoutURL', null)
amplify.store('meetingId', null)
amplify.store('messageFontSize', null)
amplify.store('tabsRenderedTime', null)
@ -346,7 +347,7 @@ Handlebars.registerHelper "visibility", (section) ->
Meteor.Users.find().observe({
removed: (oldDocument) ->
if oldDocument.userId is getInSession 'userId'
document.location = Meteor.config.app.logOutUrl
document.location = getInSession 'logoutURL'
})
# applies zooming to the stroke thickness
@ -355,17 +356,6 @@ Handlebars.registerHelper "visibility", (section) ->
ratio = (currentSlide?.slide.width_ratio + currentSlide?.slide.height_ratio) / 2
thickness * 100 / ratio
# TODO TEMPORARY!!
# must not have this in production
@whoami = ->
console.log JSON.stringify
username: getInSession "userName"
userid: getInSession "userId"
authToken: getInSession "authToken"
@listSessionVars = ->
console.log SessionAmplify.keys
# Detects a mobile device
@isMobile = ->
navigator.userAgent.match(/Android/i) or

View File

@ -17,9 +17,6 @@ config.maxChatLength = 140
## Application configurations
config.app = {}
# server ip
config.app.logOutUrl = "http://192.168.0.119/demo/demoHTML5.jsp" # TODO temporary
#default font sizes for mobile / desktop
config.app.mobileFont = 24
config.app.desktopFont = 12

View File

@ -18,7 +18,7 @@
Meteor.call("userLogout", meetingId, userId, authToken)
clearSessionVar (alert "Please sign in again")
document.location = Meteor.config.app.logOutUrl
document.location = getInSession 'logoutURL'
return
Meteor.subscribe 'chat', meetingId, userId, authToken, onError: onErrorFunction, onReady: =>
@ -30,6 +30,15 @@
# 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')
@route "main",
@ -41,10 +50,8 @@
# 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
# if their data is invalid, redirect the user to the logout page
document.location = getInSession 'logoutURL'
else
Meteor.call("validateAuthToken", meetingId, userId, authToken)

View File

@ -66,5 +66,5 @@ viewer =
else
Meteor.log.error "in meetingId=#{meetingId} userId=#{userId} tried to perform #{action} without permission" +
"\n..while the authToken was #{user.authToken} and the user's object is #{JSON.stringify user}"
"\n..while the authToken was #{user?.authToken} and the user's object is #{JSON.stringify user}"
return false