From d7324bd743ed3b57298a9c8a2816bd6304ef9138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A1ssio=20Zen?= Date: Wed, 20 Jul 2016 13:46:52 -0300 Subject: [PATCH] seting site_id automatically only for localhost --- src/backends/github/AuthenticationPage.js | 7 ++++++- src/lib/netlify-auth.js | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/backends/github/AuthenticationPage.js b/src/backends/github/AuthenticationPage.js index 97cec461..f7100604 100644 --- a/src/backends/github/AuthenticationPage.js +++ b/src/backends/github/AuthenticationPage.js @@ -14,8 +14,13 @@ export default class AuthenticationPage extends React.Component { handleLogin(e) { e.preventDefault(); + let auth; + if (document.location.host.split(':')[0] === 'localhost') { + auth = new Authenticator({ site_id: 'cms.netlify.com' }); + } else { + auth = new Authenticator(); + } - const auth = new Authenticator({site_id: 'cms.netlify.com'}); auth.authenticate({provider: 'github', scope: 'repo'}, (err, data) => { if (err) { this.setState({loginError: err.toString()}); diff --git a/src/lib/netlify-auth.js b/src/lib/netlify-auth.js index 54a75283..b22b8c6b 100644 --- a/src/lib/netlify-auth.js +++ b/src/lib/netlify-auth.js @@ -29,8 +29,8 @@ const PROVIDERS = { }; class Authenticator { - constructor(config) { - this.site_id = config.site_id; + constructor(config = {}) { + this.site_id = config.site_id || null; this.base_url = config.base_url || NETLIFY_API; }