fix: change default open authoring scope, make it configurable (#2821)

This commit is contained in:
Erez Rokah
2019-11-07 19:39:47 +02:00
committed by Shawn Erquhart
parent da2dab305a
commit 002cdd77a8
3 changed files with 61 additions and 19 deletions

View File

@ -75,12 +75,17 @@ export default class GitHubAuthenticationPage extends React.Component {
};
const auth = new NetlifyAuthenticator(cfg);
auth.authenticate({ provider: 'github', scope: 'repo' }, (err, data) => {
const openAuthoring = this.props.config.getIn(['backend', 'open_authoring'], false);
const scope = this.props.config.getIn(
['backend', 'auth_scope'],
openAuthoring ? 'public_repo' : 'repo',
);
auth.authenticate({ provider: 'github', scope }, (err, data) => {
if (err) {
this.setState({ loginError: err.toString() });
return;
}
if (this.props.config.getIn(['backend', 'open_authoring'])) {
if (openAuthoring) {
return this.loginWithOpenAuthoring(data).then(() => this.props.onLogin(data));
}
this.props.onLogin(data);