From 846520626667405d9e680ef549a32faf8048f69a Mon Sep 17 00:00:00 2001 From: esalling23 Date: Thu, 7 Jan 2021 12:00:56 -0500 Subject: [PATCH 1/3] Adds host prop to allow for github enterprise login - Adds `host` prop of type string - `host` default value is `"https://github.com"` - Example file shows sending a custom enterprise host for login with an enterprise OAuth app --- example/index.js | 1 + src/GitHubLogin.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/example/index.js b/example/index.js index af29069..42e9f29 100644 --- a/example/index.js +++ b/example/index.js @@ -8,6 +8,7 @@ const onFailure = response => console.error(response); ReactDOM.render( , document.getElementById('example') diff --git a/src/GitHubLogin.js b/src/GitHubLogin.js index e70aec3..f303480 100644 --- a/src/GitHubLogin.js +++ b/src/GitHubLogin.js @@ -15,11 +15,13 @@ class GitHubLogin extends Component { onFailure: PropTypes.func, redirectUri: PropTypes.string, scope: PropTypes.string, + host: PropTypes.string, } static defaultProps = { buttonText: 'Sign in with GitHub', redirectUri: '', + host: 'https://github.com', scope: 'user:email', onRequest: () => {}, onSuccess: () => {}, @@ -27,7 +29,7 @@ class GitHubLogin extends Component { } onBtnClick = () => { - const { clientId, scope, redirectUri } = this.props; + const { clientId, scope, redirectUri, host } = this.props; const search = toQuery({ client_id: clientId, scope, @@ -35,7 +37,7 @@ class GitHubLogin extends Component { }); const popup = this.popup = PopupWindow.open( 'github-oauth-authorize', - `https://github.com/login/oauth/authorize?${search}`, + `${host}/login/oauth/authorize?${search}`, { height: 1000, width: 600 } ); From a0eb692a6c05f6d4fd1653a9de069d28c3e823a2 Mon Sep 17 00:00:00 2001 From: esalling23 Date: Thu, 7 Jan 2021 13:10:14 -0500 Subject: [PATCH 2/3] Revert example Removes host prop example --- example/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/example/index.js b/example/index.js index 42e9f29..af29069 100644 --- a/example/index.js +++ b/example/index.js @@ -8,7 +8,6 @@ const onFailure = response => console.error(response); ReactDOM.render( , document.getElementById('example') From f9e5109e3f01b3ff836d0cd9538cd984499909dd Mon Sep 17 00:00:00 2001 From: esalling23 Date: Thu, 7 Jan 2021 13:13:27 -0500 Subject: [PATCH 3/3] Adds documentation on `host` prop --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 8beb317..aba57d0 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,12 @@ Callback for successful login. An object will be passed as an argument to the ca Callback for errors raised during login. +#### `host` + +`{string}` + +Host for Github login. Defaults to `https://github.com`. +Can be provided to allow login with Github Enterprise. ## Development