Skip to content
Snippets Groups Projects
Commit fe1d71da authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Add options to configure token path for oauth

parent d7ed9540
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,7 @@
"Accounts_OAuth_Twitter_secret": "Twitter Secret",
"Accounts_OAuth_Custom_ID": "ID",
"Accounts_OAuth_Custom_URL": "URL",
"Accounts_OAuth_Custom_Token_Path": "Token Path",
"Accounts_OAuth_Custom_Secret": "Secret",
"Accounts_OAuth_Custom_Enable": "Enable",
"Add_Members" : "Add Members",
......
......@@ -27,11 +27,11 @@ class CustomOAuth
if not Match.test options.serverURL, String
return throw new Meteor.Error 'CustomOAuth: Options.serverURL is required and must be String'
if not Match.test options.tokenURL, String
options.tokenURL = '/oauth/token'
if not Match.test options.tokenPath, String
options.tokenPath = '/oauth/token'
@serverURL = options.serverURL
@tokenURL = options.tokenURL
@tokenPath = options.tokenPath
if Match.test options.addAutopublishFields, Object
Accounts.addAutopublishFields options.addAutopublishFields
......@@ -44,8 +44,8 @@ class CustomOAuth
response = undefined
try
console.log @serverURL + @tokenURL
response = HTTP.post @serverURL + @tokenURL,
console.log @serverURL + @tokenPath
response = HTTP.post @serverURL + @tokenPath,
headers:
Accept: 'application/json'
'User-Agent': @userAgent
......
Meteor.methods
addOAuthService: (name) ->
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}" , false, { type: 'boolean', group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_Enable'}
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_url" , '' , { type: 'string' , group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_URL'}
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_id" , '' , { type: 'string' , group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_ID'}
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_secret", '' , { type: 'string' , group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_Secret'}
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}" , false , { type: 'boolean', group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_Enable'}
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_url" , '' , { type: 'string' , group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_URL'}
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_token_path", '/oauth/token' , { type: 'string' , group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_Token_Path'}
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_id" , '' , { type: 'string' , group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_ID'}
RocketChat.settings.add "Accounts_OAuth_Custom_#{name}_secret" , '' , { type: 'string' , group: 'Accounts', section: name, i18nLabel: 'Accounts_OAuth_Custom_Secret'}
......@@ -22,8 +22,10 @@ updateServices = ->
serviceName = service._id.replace('Accounts_OAuth_Custom_', '')
data.custom = true
data.serverURL = Settings.findOne({_id: "#{service._id}_url"})?.value
data.tokenPath = Settings.findOne({_id: "#{service._id}_token_path"})?.value
new CustomOAuth serviceName.toLowerCase(),
serverURL: data.serverURL
tokenPath: data.tokenPath
if serviceName is 'Facebook'
data.appId = data.clientId
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment