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

Convert packages/rocketchat-github-enterprise to JS

parent d0519dc6
No related branches found
No related tags found
No related merge requests found
# GitHub Enterprise Server CallBack URL needs to be http(s)://{rocketchat.server}[:port]/_oauth/github_enterprise
# In RocketChat -> Administration the URL needs to be http(s)://{github.enterprise.server}/
config =
serverURL: ''
identityPath: '/api/v3/user'
authorizePath: '/login/oauth/authorize'
tokenPath: '/login/oauth/access_token'
addAutopublishFields:
forLoggedInUser: ['services.github-enterprise']
forOtherUsers: ['services.github-enterprise.username']
GitHubEnterprise = new CustomOAuth 'github_enterprise', config
if Meteor.isServer
Meteor.startup ->
RocketChat.settings.get 'API_GitHub_Enterprise_URL', (key, value) ->
config.serverURL = value
GitHubEnterprise.configure config
else
Meteor.startup ->
Tracker.autorun ->
if RocketChat.settings.get 'API_GitHub_Enterprise_URL'
config.serverURL = RocketChat.settings.get 'API_GitHub_Enterprise_URL'
GitHubEnterprise.configure config
/* global CustomOAuth */
// GitHub Enterprise Server CallBack URL needs to be http(s)://{rocketchat.server}[:port]/_oauth/github_enterprise
// In RocketChat -> Administration the URL needs to be http(s)://{github.enterprise.server}/
const config = {
serverURL: '',
identityPath: '/api/v3/user',
authorizePath: '/login/oauth/authorize',
tokenPath: '/login/oauth/access_token',
addAutopublishFields: {
forLoggedInUser: ['services.github-enterprise'],
forOtherUsers: ['services.github-enterprise.username']
}
};
const GitHubEnterprise = new CustomOAuth('github_enterprise', config);
if (Meteor.isServer) {
Meteor.startup(function() {
RocketChat.settings.get('API_GitHub_Enterprise_URL', function(key, value) {
config.serverURL = value;
GitHubEnterprise.configure(config);
});
});
} else {
Meteor.startup(function() {
Tracker.autorun(function() {
if (RocketChat.settings.get('API_GitHub_Enterprise_URL')) {
config.serverURL = RocketChat.settings.get('API_GitHub_Enterprise_URL');
GitHubEnterprise.configure(config);
}
});
});
}
......@@ -6,13 +6,12 @@ Package.describe({
Package.onUse(function(api) {
api.use('ecmascript');
api.use('coffeescript');
api.use('rocketchat:lib');
api.use('rocketchat:custom-oauth');
api.use('templating', 'client');
api.addFiles('common.coffee');
api.addFiles('common.js');
api.addFiles('github-enterprise-login-button.css', 'client');
api.addFiles('startup.coffee', 'server');
api.addFiles('startup.js', 'server');
});
RocketChat.settings.addGroup 'OAuth', ->
@section 'GitHub Enterprise', ->
enableQuery = {_id: 'Accounts_OAuth_GitHub_Enterprise', value: true}
@add 'Accounts_OAuth_GitHub_Enterprise', false, {type: 'boolean'}
@add 'API_GitHub_Enterprise_URL', '', { type: 'string', public: true, enableQuery: enableQuery, i18nDescription: 'API_GitHub_Enterprise_URL_Description' }
@add 'Accounts_OAuth_GitHub_Enterprise_id', '', { type: 'string', enableQuery: enableQuery }
@add 'Accounts_OAuth_GitHub_Enterprise_secret', '', { type: 'string', enableQuery: enableQuery }
@add 'Accounts_OAuth_GitHub_Enterprise_callback_url', '_oauth/github_enterprise', { type: 'relativeUrl', readonly: true, force: true, enableQuery: enableQuery }
RocketChat.settings.addGroup('OAuth', function() {
this.section('GitHub Enterprise', function() {
const enableQuery = {
_id: 'Accounts_OAuth_GitHub_Enterprise',
value: true
};
this.add('Accounts_OAuth_GitHub_Enterprise', false, { type: 'boolean' });
this.add('API_GitHub_Enterprise_URL', '', { type: 'string', public: true, enableQuery: enableQuery, i18nDescription: 'API_GitHub_Enterprise_URL_Description' });
this.add('Accounts_OAuth_GitHub_Enterprise_id', '', { type: 'string', enableQuery: enableQuery });
this.add('Accounts_OAuth_GitHub_Enterprise_secret', '', { type: 'string', enableQuery: enableQuery });
this.add('Accounts_OAuth_GitHub_Enterprise_callback_url', '_oauth/github_enterprise', { type: 'relativeUrl', readonly: true, force: true, enableQuery: enableQuery });
});
});
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