node.jsamazon-web-servicesaws-lambdaaws-chime-sdk

Handling /join in Aws-chime-sdk(nodejs)


I'm new on nodejs and I need to edit the example code of aws-chime-sdk to build my own security check before joining a meeting.

On index portion, at handler.js, I have this code that works well:

exports.index = async (event, context, callback) => {
   // authorization code
   return response(200,'text/html','message of authorized or not');
};

I'm being able to check if the user is logged in and show/hide what they have to see.

But when joining the meeting, I can't make my authorization code to be executed, it seems to be jumping my code, and even adding a return response() at first line it's not executing, what takes me to think I'm editing the wrong place. See below:

exports.join = async (event, context, callback) => {

console.log("I'm passing by here"); //this never appears on my logs
return response(200,'text/html','test'); //this won't execute 

// here is my authorization code
// other codes

let meeting = await getMeeting(query.title);  // this is executed, the meeting is created
  if (!meeting) {
    // code for creating a new meeeting...
  }

 // and finally this seems to be returned, otherwise the meeting wouldn't work:

 return response(200, 'application/json', JSON.stringify({ 
    JoinInfo: {
      Meeting: meeting,
      Attendee: attendee,
    },
  }, null, 2));

 };

Since the form for join in a meeting at index.html has /join as target, I thought exports.join was the right place to put the check code, but I guess the request is not passing by this code. What I need is an explanation of how these requisitions occurs so I can try to handle this authorization check at the right place.

Thank you very much.


Solution

  • You have to edit the code in the respective lambda of the desired resource , in your case, the lambda that handles /Join