Get the token from the URL to authenticate the HTML5 client
This commit is contained in:
parent
08f23883e3
commit
3cc04e47c3
@ -10,28 +10,37 @@ define [
|
||||
defaults:
|
||||
username: null
|
||||
meetingId: null
|
||||
externalMeetingId: null
|
||||
userId: null
|
||||
loginAccepted: false
|
||||
|
||||
authenticate: (callbacks) ->
|
||||
# TOOD: request to /bigbluebutton/api/enter to get the meeting information
|
||||
@username = "Test Name"
|
||||
@meetingId = "183f0bf3a0982a127bdb8161e0c44eb696b3e75c-1398367421601"
|
||||
@userId = "12345678901234567890234567890"
|
||||
|
||||
message =
|
||||
"header":
|
||||
"timestamp": new Date().getTime()
|
||||
"name": "validate_auth_token_request"
|
||||
"payload":
|
||||
"auth_token": @userId
|
||||
"user_id": @userId
|
||||
"meeting_id": @meetingId
|
||||
header:
|
||||
timestamp: new Date().getTime()
|
||||
name: "validate_auth_token_request"
|
||||
payload:
|
||||
auth_token: getURLParameter("auth_token")
|
||||
|
||||
console.log "Sending authentication message", message
|
||||
globals.events.on "message", (received) ->
|
||||
globals.events.on "message", (received) =>
|
||||
console.log "Authentication response", received
|
||||
if received?.header?.name is "validate_auth_token_reply"
|
||||
@set("username", received.payload.fullname)
|
||||
@set("meetingId", received.payload.meeting_id)
|
||||
@set("externalMeetingId", received.payload.external_meeting_id)
|
||||
@set("userId", received.payload.user_id)
|
||||
callbacks(null, received)
|
||||
globals.connection.emit(message)
|
||||
|
||||
getURLParameter = (name) ->
|
||||
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]")
|
||||
regexS = "[\\?&]"+name+"=([^&#]*)"
|
||||
regex = new RegExp(regexS)
|
||||
results = regex.exec(location.search)
|
||||
unless results?
|
||||
""
|
||||
else
|
||||
decodeURIComponent(results[1].replace(/\+/g, " "))
|
||||
|
||||
AuthenticationModel
|
||||
|
@ -25,11 +25,11 @@ define [
|
||||
|
||||
# Connect to the server and authenticate the user
|
||||
globals.connection.connect()
|
||||
@_authentication()
|
||||
@_authenticate()
|
||||
|
||||
# Fetch information from the server to check if the user is autheticated
|
||||
# already or not. If not, authenticates the user.
|
||||
_authentication: ->
|
||||
_authenticate: ->
|
||||
console.log "Authenticating user"
|
||||
@model.authenticate (err, data) =>
|
||||
if not err? and data.payload?.valid
|
||||
|
@ -30,15 +30,33 @@ handleMessage = (message) ->
|
||||
|
||||
handleAuthenticateMessage = (message) ->
|
||||
console.log "Handling:", message
|
||||
|
||||
response =
|
||||
header:
|
||||
name: REPLY_MSG_NAME
|
||||
correlation_id: message.header.correlation_id
|
||||
timestamp: new Date().getTime()
|
||||
payload:
|
||||
valid: true
|
||||
auth_token: message.payload.auth_token
|
||||
user_id: message.payload.user_id
|
||||
meeting_id: message.payload.meeting_id
|
||||
fullname: "Richard Alam"
|
||||
confname: "Demo Meeting"
|
||||
meeting_id: "Demo Meeting"
|
||||
external_meeting_id: "183f0bf3a0982a127bdb8161e0c44eb696b3e75c-1398367421601"
|
||||
user_id: "12345678901234567890234567890"
|
||||
external_user_id: "12345678901234567890234567890"
|
||||
conference: "183f0bf3a0982a127bdb8161e0c44eb696b3e75c-1398367421601"
|
||||
room: "183f0bf3a0982a127bdb8161e0c44eb696b3e75c-1398367421601"
|
||||
voice_bridge: 71234
|
||||
dial_number: "613-555-1234"
|
||||
web_voice_conf: 71234
|
||||
mode: "LIVE"
|
||||
record: false
|
||||
welcome: "Welcome to my humble meeting."
|
||||
logout_url: "http://10.0.3.181"
|
||||
default_layout: "NOLAYOUT"
|
||||
avatar_url: "http://10.0.3.181/client/avatar.png"
|
||||
|
||||
console.log "Publishing", response, "to", PUBLISH_CHANNEL
|
||||
subClient.publish(PUBLISH_CHANNEL, JSON.stringify(response))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user