Skip to content

Commit

Permalink
refactor: remove meteor from githubenterprise auth
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSchoeler committed Jan 21, 2025
1 parent a5b4584 commit 5b5da19
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
20 changes: 11 additions & 9 deletions apps/meteor/app/github-enterprise/client/lib.ts
Original file line number Diff line number Diff line change
@@ -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';

// 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}/
Expand All @@ -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 useGitHubEnterprise = () => {
const githubApiUrl = useSetting('API_GitHub_Enterprise_URL') as string;

useEffect(() => {
if (githubApiUrl) {
config.serverURL = githubApiUrl;
GitHubEnterprise.configure(config);
}
});
});
}, [githubApiUrl]);
};
3 changes: 3 additions & 0 deletions apps/meteor/client/views/root/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useEscapeKeyStroke } from './hooks/useEscapeKeyStroke';
import { useGoogleTagManager } from './hooks/useGoogleTagManager';
import { useMessageLinkClicks } from './hooks/useMessageLinkClicks';
import { useAnalytics } from '../../../app/analytics/client/loadScript';
import { useGitHubEnterprise } from '../../../app/github-enterprise/client/lib';
import { useAnalyticsEventTracking } from '../../hooks/useAnalyticsEventTracking';
import { useLoadRoomForAllowedAnonymousRead } from '../../hooks/useLoadRoomForAllowedAnonymousRead';
import { useNotifyUser } from '../../hooks/useNotifyUser';
Expand All @@ -29,6 +30,8 @@ const AppLayout = () => {
useLoadRoomForAllowedAnonymousRead();
useNotifyUser();

useGitHubEnterprise();

const layout = useSyncExternalStore(appLayout.subscribe, appLayout.getSnapshot);

return (
Expand Down

0 comments on commit 5b5da19

Please sign in to comment.