|
|
@ -24,6 +24,7 @@ export default class Login extends React.Component { |
|
|
|
render() { |
|
|
|
render() { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="login jumbotron center-block"> |
|
|
|
<div className="login jumbotron center-block"> |
|
|
|
|
|
|
|
{/* |
|
|
|
<h1>Login</h1> |
|
|
|
<h1>Login</h1> |
|
|
|
<form role="form"> |
|
|
|
<form role="form"> |
|
|
|
<div className="form-group"> |
|
|
|
<div className="form-group"> |
|
|
@ -36,9 +37,65 @@ export default class Login extends React.Component { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<button type="submit" className="btn btn-default" onClick={this.login.bind(this)}>Submit</button> |
|
|
|
<button type="submit" className="btn btn-default" onClick={this.login.bind(this)}>Submit</button> |
|
|
|
</form> |
|
|
|
</form> |
|
|
|
|
|
|
|
*/} |
|
|
|
|
|
|
|
<a href="#" className="fb-login-button" data-max-rows="1" data-size="large" onClick={this.handleClickFb.bind(this)}>FB Login</a> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() { |
|
|
|
|
|
|
|
window.fbAsyncInit = function() { |
|
|
|
|
|
|
|
FB.init({ |
|
|
|
|
|
|
|
appId : '147935535403714', |
|
|
|
|
|
|
|
xfbml : true, |
|
|
|
|
|
|
|
version : 'v2.5' |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
FB.getLoginStatus(function(response) { |
|
|
|
|
|
|
|
this.statusChangeCallback(response); |
|
|
|
|
|
|
|
}.bind(this)) |
|
|
|
|
|
|
|
}.bind(this) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
componentWillMount() { |
|
|
|
|
|
|
|
(function(d, s, id){ |
|
|
|
|
|
|
|
var js, fjs = d.getElementsByTagName(s)[0]; |
|
|
|
|
|
|
|
if (d.getElementById(id)) {return;} |
|
|
|
|
|
|
|
js = d.createElement(s); js.id = id; |
|
|
|
|
|
|
|
js.src = '//connect.facebook.net/en_US/sdk.js'; |
|
|
|
|
|
|
|
fjs.parentNode.insertBefore(js, fjs); |
|
|
|
|
|
|
|
}(document, 'script', 'facebook-jssdk')); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
statusChangeCallback(response) { |
|
|
|
|
|
|
|
if (response.status === 'connected') { |
|
|
|
|
|
|
|
var access_token = response.authResponse.accessToken; |
|
|
|
|
|
|
|
Auth.socialLogin('facebook', access_token); |
|
|
|
|
|
|
|
// console.log(access_token);
|
|
|
|
|
|
|
|
// FB.api('/me', { locale: 'en_US', fields: 'first_name, email, picture' },
|
|
|
|
|
|
|
|
// function(response) {
|
|
|
|
|
|
|
|
// console.log(response);
|
|
|
|
|
|
|
|
// Auth.socialLogin('facebook', access_token, response.email, response.first_name);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
} else if (response.status === 'not_authorized') { |
|
|
|
|
|
|
|
console.log('not not_authorized'); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
console.log('not logged into facebook'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
checkLoginState() { |
|
|
|
|
|
|
|
FB.getLoginStatus((response) => { |
|
|
|
|
|
|
|
this.statusChangeCallback(response); |
|
|
|
|
|
|
|
}.bind(this)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handleClickFb() { |
|
|
|
|
|
|
|
FB.login((response) => { |
|
|
|
|
|
|
|
this.statusChangeCallback(response); |
|
|
|
|
|
|
|
}, {scope: 'email', return_scopes: true}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ReactMixin(Login.prototype, React.addons.LinkedStateMixin); |
|
|
|
ReactMixin(Login.prototype, React.addons.LinkedStateMixin); |
|
|
|