|
|
|
|
@ -1,9 +1,8 @@ |
|
|
|
|
import type { OauthConfig } from '@rocket.chat/core-typings'; |
|
|
|
|
import { Meteor } from 'meteor/meteor'; |
|
|
|
|
import { Tracker } from 'meteor/tracker'; |
|
|
|
|
import { useSetting } from '@rocket.chat/ui-contexts'; |
|
|
|
|
import { useEffect } from 'react'; |
|
|
|
|
|
|
|
|
|
import { CustomOAuth } from '../../custom-oauth/client/CustomOAuth'; |
|
|
|
|
import { settings } from '../../settings/client'; |
|
|
|
|
import { CustomOAuth } from '../../../custom-oauth/client/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}/
|
|
|
|
|
@ -20,11 +19,14 @@ const config: OauthConfig = { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const GitHubEnterprise = new CustomOAuth('github_enterprise', config); |
|
|
|
|
Meteor.startup(() => { |
|
|
|
|
Tracker.autorun(() => { |
|
|
|
|
if (settings.get('API_GitHub_Enterprise_URL')) { |
|
|
|
|
config.serverURL = settings.get('API_GitHub_Enterprise_URL'); |
|
|
|
|
|
|
|
|
|
export const useGitHubEnterpriseAuth = () => { |
|
|
|
|
const githubApiUrl = useSetting('API_GitHub_Enterprise_URL') as string; |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (githubApiUrl) { |
|
|
|
|
config.serverURL = githubApiUrl; |
|
|
|
|
GitHubEnterprise.configure(config); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}, [githubApiUrl]); |
|
|
|
|
}; |