From 7580234370746a072e52f69c6bccef104a370c2a Mon Sep 17 00:00:00 2001 From: Javi Date: Mon, 25 Jul 2016 12:24:51 +0200 Subject: [PATCH 1/2] - Added state param. --- index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index e403699..6a44e74 100644 --- a/index.js +++ b/index.js @@ -8,6 +8,16 @@ const nodeUrl = require('url'); const electron = require('electron'); const BrowserWindow = electron.BrowserWindow || electron.remote.BrowserWindow; +var generateRandomString = function(length) { + var text = ''; + var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + + for (var i = 0; i < length; i++) { + text += possible.charAt(Math.floor(Math.random() * possible.length)); + } + return text; +}; + module.exports = function (config, windowParams) { function getAuthorizationCode(opts) { opts = opts || {}; @@ -19,7 +29,8 @@ module.exports = function (config, windowParams) { var urlParams = { response_type: 'code', redirect_uri: config.redirectUri, - client_id: config.clientId + client_id: config.clientId, + state: generateRandomString(16) }; if (opts.scope) { From 11eae1e63e052a73f14d7bb43c1a8f0cf9dc2f43 Mon Sep 17 00:00:00 2001 From: John Ferlito Date: Wed, 26 Apr 2017 19:58:23 +1000 Subject: [PATCH 2/2] Fix formatting --- index.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 6a44e74..42698ce 100644 --- a/index.js +++ b/index.js @@ -8,14 +8,15 @@ const nodeUrl = require('url'); const electron = require('electron'); const BrowserWindow = electron.BrowserWindow || electron.remote.BrowserWindow; -var generateRandomString = function(length) { - var text = ''; - var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; +var generateRandomString = function (length) { + var text = ''; + var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - for (var i = 0; i < length; i++) { - text += possible.charAt(Math.floor(Math.random() * possible.length)); - } - return text; + for (var i = 0; i < length; i++) { + text += possible.charAt(Math.floor(Math.random() * possible.length)); + } + + return text; }; module.exports = function (config, windowParams) {