Skip to content

Commit 449e639

Browse files
committed
changing auth of fb login
1 parent 79d261e commit 449e639

File tree

1 file changed

+34
-30
lines changed

1 file changed

+34
-30
lines changed

js/login.js

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
11
"use strict";
22

3-
window.fbAsyncInit = function() {
4-
FB.init({
5-
appId : '932297393472020',
6-
xfbml : true,
7-
version : 'v2.5'
8-
});
3+
window.onload = function() {
4+
window.fbAsyncInit = function() {
5+
FB.init({
6+
appId : '932297393472020',
7+
xfbml : true,
8+
version : 'v2.5'
9+
});
910
};
1011

11-
(function(d, s, id){
12-
var js, fjs = d.getElementsByTagName(s)[0];
13-
if (d.getElementById(id)) {return;}
14-
js = d.createElement(s); js.id = id;
15-
js.src = "//connect.facebook.net/en_US/sdk.js";
16-
fjs.parentNode.insertBefore(js, fjs);
17-
}(document, 'script', 'facebook-jssdk'));
12+
(function(d, s, id) {
13+
var js, fjs = d.getElementsByTagName(s)[0];
14+
if (d.getElementById(id)) {
15+
return;
16+
}
17+
js = d.createElement(s); js.id = id;
18+
js.src = "//connect.facebook.net/en_US/sdk.js";
19+
fjs.parentNode.insertBefore(js, fjs);
20+
}(document, 'script', 'facebook-jssdk'));
1821

19-
var accessKey;
20-
21-
function statusChangeCallback(response) {
22-
23-
if (response.status === 'connected') {
24-
console.log("connected!");
22+
var accessKey;
23+
24+
function statusChangeCallback(response) {
25+
26+
if (response.status === 'connected') {
27+
console.log("connected!");
2528
// Logged into your app and Facebook.
2629
accessKey = response.authResponse.accessToken;
27-
} else if (response.status === 'not_authorized') {
28-
console.log("needs to log into app");
29-
} else {
30-
console.log("needs to log into fb");
31-
}
32-
}
30+
} else if (response.status === 'not_authorized') {
31+
console.log("needs to log into app");
32+
} else {
33+
console.log("needs to log into fb");
34+
}
35+
}
3336

34-
function checkLoginState() {
35-
FB.getLoginStatus(function(response) {
36-
statusChangeCallback(response);
37-
});
38-
}
37+
function checkLoginState() {
38+
FB.getLoginStatus(function(response) {
39+
statusChangeCallback(response);
40+
});
41+
}
42+
};

0 commit comments

Comments
 (0)