Skip to content

Commit

Permalink
Close #861; Fix Gitlab oAuth url from API_Gitlab_URL
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigok committed Sep 23, 2015
1 parent 0d8bf59 commit b14954a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
17 changes: 10 additions & 7 deletions packages/rocketchat-custom-oauth/custom_oauth_client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ class CustomOAuth
if not Match.test @name, String
return throw new Meteor.Error 'CustomOAuth: Name is required and must be String'

@configure options

Accounts.oauth.registerService @name

@configureLogin()

configure: (options) ->
if not Match.test options, Object
return throw new Meteor.Error 'CustomOAuth: Options is required and must be Object'

Expand All @@ -20,13 +27,9 @@ class CustomOAuth
@serverURL = options.serverURL

if not /^https?:\/\/.+/.test options.authorizePath
options.authorizePath = @serverURL + options.authorizePath

@authorizePath = options.authorizePath

Accounts.oauth.registerService @name

@configureLogin()
@authorizePath = @serverURL + options.authorizePath
else
@authorizePath = options.authorizePath

configureLogin: ->
self = @
Expand Down
7 changes: 5 additions & 2 deletions packages/rocketchat-gitlab/common.coffee
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
Gitlab = new CustomOAuth 'gitlab',
config =
serverURL: 'https://gitlab.com'
identityPath: '/api/v3/user'
addAutopublishFields:
forLoggedInUser: ['services.gitlab']
forOtherUsers: ['services.gitlab.username']

Gitlab = new CustomOAuth 'gitlab', config

Meteor.startup ->
Tracker.autorun ->
if RocketChat.settings.get 'API_Gitlab_URL'
Gitlab.serverURL = RocketChat.settings.get 'API_Gitlab_URL'
config.serverURL = RocketChat.settings.get 'API_Gitlab_URL'
Gitlab.configure config

0 comments on commit b14954a

Please sign in to comment.