From 955a32c972514fb73b7434a047ce1fce5356455f Mon Sep 17 00:00:00 2001
From: Marcelo Schmidt <marcelo.schmidt@konecty.com>
Date: Fri, 4 Mar 2016 18:23:27 -0300
Subject: [PATCH] Fixes #2052. Shows OAuth Callback URLs

---
 i18n/en.i18n.json                                        | 7 +++++++
 packages/rocketchat-github-enterprise/i18n/en.i18n.json  | 1 +
 packages/rocketchat-github-enterprise/startup.coffee     | 1 +
 packages/rocketchat-lib/server/functions/settings.coffee | 2 +-
 packages/rocketchat-lib/server/startup/settings.coffee   | 7 +++++++
 packages/rocketchat-wordpress/i18n/en.i18n.json          | 3 ++-
 packages/rocketchat-wordpress/startup.coffee             | 1 +
 7 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json
index 3703ffdeb01..32a2e5d4a72 100644
--- a/i18n/en.i18n.json
+++ b/i18n/en.i18n.json
@@ -40,24 +40,31 @@
   "Accounts_OAuth_Facebook" : "Facebook Login",
   "Accounts_OAuth_Facebook_id" : "Facebook App Id",
   "Accounts_OAuth_Facebook_secret" : "Facebook Secret",
+  "Accounts_OAuth_Facebook_callback_url" : "Facebook Callback URL",
   "Accounts_OAuth_Github" : "OAuth Enabled",
   "Accounts_OAuth_Github_id" : "Client Id",
   "Accounts_OAuth_Github_secret" : "Client Secret",
+  "Accounts_OAuth_Github_callback_url" : "Github Callback URL",
   "Accounts_OAuth_Gitlab" : "OAuth Enabled",
   "Accounts_OAuth_Gitlab_id" : "Gitlab Id",
   "Accounts_OAuth_Gitlab_secret" : "Client Secret",
+  "Accounts_OAuth_Gitlab_callback_url" : "Gitlab Callback URL",
   "Accounts_OAuth_Google" : "Google Login",
   "Accounts_OAuth_Google_id" : "Google Id",
   "Accounts_OAuth_Google_secret" : "Google Secret",
+  "Accounts_OAuth_Google_callback_url" : "Google Callback URL",
   "Accounts_OAuth_Linkedin" : "LinkedIn Login",
   "Accounts_OAuth_Linkedin_id" : "LinkedIn Id",
   "Accounts_OAuth_Linkedin_secret" : "LinkedIn Secret",
+  "Accounts_OAuth_Linkedin_callback_url" : "Linkedin Callback URL",
   "Accounts_OAuth_Meteor" : "Meteor Login",
   "Accounts_OAuth_Meteor_id" : "Meteor Id",
   "Accounts_OAuth_Meteor_secret" : "Meteor Secret",
+  "Accounts_OAuth_Meteor_callback_url" : "Meteor Callback URL",
   "Accounts_OAuth_Twitter" : "Twitter Login",
   "Accounts_OAuth_Twitter_id" : "Twitter Id",
   "Accounts_OAuth_Twitter_secret" : "Twitter Secret",
+  "Accounts_OAuth_Twitter_callback_url" : "Twitter Callback URL",
   "Accounts_PasswordReset" : "Password Reset",
   "Accounts_Registration_AuthenticationServices_Enabled" : "Registration with Authentication Services",
   "Accounts_RegistrationForm" : "Registration Form",
diff --git a/packages/rocketchat-github-enterprise/i18n/en.i18n.json b/packages/rocketchat-github-enterprise/i18n/en.i18n.json
index 6bd78273fc7..ccb8fd79c81 100644
--- a/packages/rocketchat-github-enterprise/i18n/en.i18n.json
+++ b/packages/rocketchat-github-enterprise/i18n/en.i18n.json
@@ -3,5 +3,6 @@
   "API_GitHub_Enterprise_URL" : "Server URL",
   "Accounts_OAuth_GitHub_Enterprise_id" : "Client Id",
   "Accounts_OAuth_GitHub_Enterprise_secret" : "Client Secret",
+  "Accounts_OAuth_GitHub_Enterprise_callback_url" : "Github Enterprise Callback URL",
   "Github_Enterprise_Url_No_Trail" : "Example: http://domain.com (excluding trailing slash)"
 }
\ No newline at end of file
diff --git a/packages/rocketchat-github-enterprise/startup.coffee b/packages/rocketchat-github-enterprise/startup.coffee
index 2ca75ae78c0..f648d6e52bc 100644
--- a/packages/rocketchat-github-enterprise/startup.coffee
+++ b/packages/rocketchat-github-enterprise/startup.coffee
@@ -4,3 +4,4 @@ Meteor.startup ->
   RocketChat.settings.add 'API_GitHub_Enterprise_URL', '', { type: 'string', group: 'Accounts', public: true, section: 'GitHub Enterprise', i18nLabel: 'API_GitHub_Enterprise_URL', i18nDescription: 'Github_Enterprise_Url_No_Trail' }
   RocketChat.settings.add	'Accounts_OAuth_GitHub_Enterprise_id', '', { type: 'string', group: 'Accounts', section: 'GitHub Enterprise', i18nLabel: 'Accounts_OAuth_GitHub_Enterprise_id' }
   RocketChat.settings.add	'Accounts_OAuth_GitHub_Enterprise_secret', '', { type: 'string', group: 'Accounts', section: 'GitHub Enterprise', i18nLabel: 'Accounts_OAuth_GitHub_Enterprise_secret' }
+  RocketChat.settings.add	'Accounts_OAuth_GitHub_Enterprise_callback_url', __meteor_runtime_config__?.ROOT_URL + '_oauth/github_enterprise', { type: 'string', blocked: true }
\ No newline at end of file
diff --git a/packages/rocketchat-lib/server/functions/settings.coffee b/packages/rocketchat-lib/server/functions/settings.coffee
index ba72089542c..27c08833d5e 100644
--- a/packages/rocketchat-lib/server/functions/settings.coffee
+++ b/packages/rocketchat-lib/server/functions/settings.coffee
@@ -24,7 +24,7 @@ RocketChat.settings.add = (_id, value, options = {}) ->
 	options.valueSource = 'packageValue'
 	options.ts = new Date
 	options.hidden = false
-	options.blocked = false
+	options.blocked = options.blocked || false
 	options.sorter ?= RocketChat.settings._sorter++
 
 	if options.enableQuery?
diff --git a/packages/rocketchat-lib/server/startup/settings.coffee b/packages/rocketchat-lib/server/startup/settings.coffee
index 3a78e51441a..bcaf3d17a00 100644
--- a/packages/rocketchat-lib/server/startup/settings.coffee
+++ b/packages/rocketchat-lib/server/startup/settings.coffee
@@ -35,36 +35,43 @@ RocketChat.settings.addGroup 'Accounts', ->
 		@add 'Accounts_OAuth_Facebook', false, { type: 'boolean', public: true }
 		@add 'Accounts_OAuth_Facebook_id', '', { type: 'string', enableQuery: {_id: 'Accounts_OAuth_Facebook', value: true} }
 		@add 'Accounts_OAuth_Facebook_secret', '', { type: 'string', enableQuery: {_id: 'Accounts_OAuth_Facebook', value: true} }
+		@add 'Accounts_OAuth_Facebook_callback_url', __meteor_runtime_config__?.ROOT_URL + '_oauth/facebook', { type: 'string', blocked: true }
 
 	@section 'Google', ->
 		@add 'Accounts_OAuth_Google', false, { type: 'boolean', public: true }
 		@add 'Accounts_OAuth_Google_id', '', { type: 'string', enableQuery: {_id: 'Accounts_OAuth_Google', value: true} }
 		@add 'Accounts_OAuth_Google_secret', '', { type: 'string', enableQuery: {_id: 'Accounts_OAuth_Google', value: true} }
+		@add 'Accounts_OAuth_Google_callback_url', __meteor_runtime_config__?.ROOT_URL + '_oauth/google', { type: 'string', blocked: true }
 
 	@section 'Github', ->
 		@add 'Accounts_OAuth_Github', false, { type: 'boolean', public: true }
 		@add 'Accounts_OAuth_Github_id', '', { type: 'string', enableQuery: {_id: 'Accounts_OAuth_Github', value: true} }
 		@add 'Accounts_OAuth_Github_secret', '', { type: 'string', enableQuery: {_id: 'Accounts_OAuth_Github', value: true} }
+		@add 'Accounts_OAuth_Github_callback_url', __meteor_runtime_config__?.ROOT_URL + '_oauth/github', { type: 'string', blocked: true }
 
 	@section 'Gitlab', ->
 		@add 'Accounts_OAuth_Gitlab', false, { type: 'boolean', public: true }
 		@add 'Accounts_OAuth_Gitlab_id', '', { type: 'string', enableQuery: {_id: 'Accounts_OAuth_Gitlab', value: true} }
 		@add 'Accounts_OAuth_Gitlab_secret', '', { type: 'string', enableQuery: {_id: 'Accounts_OAuth_Gitlab', value: true} }
+		@add 'Accounts_OAuth_Gitlab_callback_url', __meteor_runtime_config__?.ROOT_URL + '_oauth/gitlab', { type: 'string', blocked: true }
 
 	@section 'Linkedin', ->
 		@add 'Accounts_OAuth_Linkedin', false, { type: 'boolean', public: true }
 		@add 'Accounts_OAuth_Linkedin_id', '', { type: 'string', enableQuery: {_id: 'Accounts_OAuth_Linkedin', value: true} }
 		@add 'Accounts_OAuth_Linkedin_secret', '', { type: 'string', enableQuery: {_id: 'Accounts_OAuth_Linkedin', value: true} }
+		@add 'Accounts_OAuth_Linkedin_callback_url', __meteor_runtime_config__?.ROOT_URL + '_oauth/linkedin', { type: 'string', blocked: true }
 
 	@section 'Meteor', ->
 		@add 'Accounts_OAuth_Meteor', false, { type: 'boolean', public: true }
 		@add 'Accounts_OAuth_Meteor_id', '', { type: 'string', enableQuery: {_id: 'Accounts_OAuth_Meteor', value: true} }
 		@add 'Accounts_OAuth_Meteor_secret', '', { type: 'string', enableQuery: {_id: 'Accounts_OAuth_Meteor', value: true} }
+		@add 'Accounts_OAuth_Meteor_callback_url', __meteor_runtime_config__?.ROOT_URL + '_oauth/meteor', { type: 'string', blocked: true }
 
 	@section 'Twitter', ->
 		@add 'Accounts_OAuth_Twitter', false, { type: 'boolean', public: true }
 		@add 'Accounts_OAuth_Twitter_id', '', { type: 'string', enableQuery: {_id: 'Accounts_OAuth_Twitter', value: true} }
 		@add 'Accounts_OAuth_Twitter_secret', '', { type: 'string', enableQuery: {_id: 'Accounts_OAuth_Twitter', value: true} }
+		@add 'Accounts_OAuth_Twitter_callback_url', __meteor_runtime_config__?.ROOT_URL + '_oauth/twitter', { type: 'string', blocked: true }
 
 
 RocketChat.settings.addGroup 'FileUpload', ->
diff --git a/packages/rocketchat-wordpress/i18n/en.i18n.json b/packages/rocketchat-wordpress/i18n/en.i18n.json
index 06727b945fe..20cb1ccaa19 100644
--- a/packages/rocketchat-wordpress/i18n/en.i18n.json
+++ b/packages/rocketchat-wordpress/i18n/en.i18n.json
@@ -2,5 +2,6 @@
   "API_Wordpress_URL" : "WordPress URL",
   "Accounts_OAuth_Wordpress" : "WordPress Login",
   "Accounts_OAuth_Wordpress_id" : "WordPress Id",
-  "Accounts_OAuth_Wordpress_secret" : "WordPress Secret"
+  "Accounts_OAuth_Wordpress_secret" : "WordPress Secret",
+  "Accounts_OAuth_Wordpress_callback_url" : "Wordpress Callback URL"
 }
\ No newline at end of file
diff --git a/packages/rocketchat-wordpress/startup.coffee b/packages/rocketchat-wordpress/startup.coffee
index b7d7dec50b3..1386cc1c024 100644
--- a/packages/rocketchat-wordpress/startup.coffee
+++ b/packages/rocketchat-wordpress/startup.coffee
@@ -2,4 +2,5 @@ RocketChat.settings.add 'API_Wordpress_URL', '', { type: 'string', group: 'Accou
 RocketChat.settings.add 'Accounts_OAuth_Wordpress', false, { type: 'boolean', group: 'Accounts', section: 'WordPress' }
 RocketChat.settings.add 'Accounts_OAuth_Wordpress_id', '', { type: 'string', group: 'Accounts', section: 'WordPress' }
 RocketChat.settings.add 'Accounts_OAuth_Wordpress_secret', '', { type: 'string', group: 'Accounts', section: 'WordPress' }
+RocketChat.settings.add 'Accounts_OAuth_Wordpress_callback_url', __meteor_runtime_config__?.ROOT_URL + '_oauth/wordpress', { type: 'string', blocked: true }
 
-- 
GitLab