From bcb7fdf0328e67384eb97572c8101334ec41cdd7 Mon Sep 17 00:00:00 2001 From: Kanishk Mehta Date: Wed, 27 Sep 2017 12:58:32 +0530 Subject: [PATCH] Send magic code to user in HTML instead of JSON Lines 93 to 103 added **for users who are deploying the bot on a website**, if they want the user to receive the authentication code in html format (since some browsers don't support JSON..like IE) to improve user experience. In order to use this, simply comment line 91 and un-comment 93 to 103. Thought it might help. --- app.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 392e3aa..3f330be 100644 --- a/app.js +++ b/app.js @@ -89,6 +89,18 @@ server.get('/api/OAuthCallback/', bot.receive(continueMsg.toMessage()); res.send('Welcome ' + req.user.displayName + '! Please copy this number and paste it back to your chat so your authentication can complete: ' + magicCode); + + /* //For users who are deploying the bot on a website, if they want the user to receive the authentication code in html format (since some browsers don't support JSON..like IE) to improve user experience, Please replace line num 91 (res.send...) with the code below (or uncomment this code snippet): + + var body = 'Welcome ' + req.user.displayName + '! Please copy this number and paste it back to your chat so your authentication can complete: ' + magicCode''; + res.writeHead(200, { + 'Content-Length': Buffer.byteLength(body), + 'Content-Type': 'text/html' + }); + res.write(body); + res.end(); + + */ }); passport.serializeUser(function(user, done) { @@ -392,4 +404,4 @@ function getUserLatestEmail(accessToken, callback) { }).on('error', function (e) { callback(e, null); }); -} \ No newline at end of file +}