From 3d09b3cf450569dcd8df9b05132270595b22087b Mon Sep 17 00:00:00 2001 From: Hemant Mann Date: Sat, 8 Jul 2017 22:04:25 +0530 Subject: [PATCH 1/2] Fix Event Trigger Event was triggered on storage selection if code={something} was present in URL --- apps/files_external/js/oauth2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_external/js/oauth2.js b/apps/files_external/js/oauth2.js index 5393ac9c96c8..945a60c3b8be 100644 --- a/apps/files_external/js/oauth2.js +++ b/apps/files_external/js/oauth2.js @@ -27,7 +27,7 @@ $(document).ready(function() { params[key] = value; }); - if (params['code'] !== undefined) { + if (params['code'] !== undefined && client_id != '' && client_secret != '') { $('.configuration').trigger('oauth_step2', [{ backend_id: $tr.attr('class'), client_id: client_id, From d974db3af238e4f493db78a79fe9164189040bbe Mon Sep 17 00:00:00 2001 From: Hemant Mann Date: Thu, 13 Jul 2017 21:16:57 +0530 Subject: [PATCH 2/2] Strict checking --- apps/files_external/js/oauth2.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/files_external/js/oauth2.js b/apps/files_external/js/oauth2.js index 945a60c3b8be..4a018fc001f7 100644 --- a/apps/files_external/js/oauth2.js +++ b/apps/files_external/js/oauth2.js @@ -27,14 +27,20 @@ $(document).ready(function() { params[key] = value; }); - if (params['code'] !== undefined && client_id != '' && client_secret != '') { + if ( + params.code !== undefined + && typeof client_id === "string" + && client_id !== '' + && typeof client_secret === "string" + && client_secret !== '' + ) { $('.configuration').trigger('oauth_step2', [{ backend_id: $tr.attr('class'), client_id: client_id, client_secret: client_secret, redirect: location.protocol + '//' + location.host + location.pathname + '?sectionid=storage', tr: $tr, - code: params['code'] || '', + code: params.code || '' }]); } } @@ -48,14 +54,14 @@ $(document).ready(function() { var client_id = $(this).parent().find('[data-parameter="client_id"]').val(); var client_secret = $(this).parent().find('[data-parameter="client_secret"]').val(); - if (client_id != '' && client_secret != '') { + if (client_id !== '' && client_secret !== '') { $('.configuration').trigger('oauth_step1', [{ backend_id: tr.attr('class'), client_id: client_id, client_secret: client_secret, redirect: location.protocol + '//' + location.host + location.pathname + '?sectionid=storage', tr: tr - }]) + }]); } });