Add allow signup option to GitHub OAuth

This commit is contained in:
Jan Dvorak
2021-10-27 19:53:45 +02:00
parent 49f99b1d1c
commit 2415d61648
2 changed files with 7 additions and 1 deletions

View File

@@ -8,6 +8,7 @@
* `github-oauth@1.4.0`
- More data will be retrieved and saved under `services.github` on the user account.
- Add option to disallow sign-up on GitHub using `allow_signup` [parameter](https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps#parameters), this will be activated based on your Accounts settings, specifically if the option `forbidClientAccountCreation` is set to `true`.
#### Independent Releases

View File

@@ -25,12 +25,17 @@ Github.requestCredential = (options, credentialRequestCompleteCallback) => {
const loginStyle = OAuth._loginStyle('github', config, options);
let allowSignup = '';
if (Accounts._options?.forbidClientAccountCreation)
allowSignup = '&allow_signup=false'; // https://docs.github.com/en/developers/apps/building-oauth-apps/authorizing-oauth-apps#parameters
const loginUrl =
'https://github.com/login/oauth/authorize' +
`?client_id=${config.clientId}` +
`&scope=${flatScope}` +
`&redirect_uri=${OAuth._redirectUri('github', config)}` +
`&state=${OAuth._stateParam(loginStyle, credentialToken, options && options.redirectUrl)}`;
`&state=${OAuth._stateParam(loginStyle, credentialToken, options && options.redirectUrl)}` +
allowSignup;
OAuth.launchLogin({
loginService: "github",