Answer the question
In order to leave comments, you need to log in
Authorization in facebook, the login window does not close after logging in?
CLEAR. It worked, by itself.
You need to close the window, and do not reload the page.
I am writing a microlib for cross-social authorization. When calling the FB.login() method, an authorization popup is opened, after submitting the popup is not closed. Just an empty popup will remain. The code:
function Social ( name ) {
var social = this,
init = function () {
social[ name ].init()
}
social.checkAuth = function ( callback ) {
social[ name ].checkAuth( callback )
}
social.login = function ( callback ) {
social[ name ].login( callback )
}
social.logout = function ( callback ) {
social[ name ].logout( callback )
}
init()
}
Social.prototype.facebook = new function () {
var fb = this
fb.init = function () {
window.fbAsyncInit = function() {
FB.init({
appId : socialSettings.fb.appId,
channelUrl : widgetUrl,
status : true,
cookie : true,
xfbml : true
})
FB.getLoginStatus(function(response) {
fb.status = response
})
}
async(function() {
$( 'body' ).append( '<div id="fb-root" style="display: none" />' )
var js,
d = document,
id = 'facebook-jssdk'
if ( d.getElementById( id ) ) return
js = d.createElement( 'script' )
js.type = "text/javascript"
js.id = id
js.async = true
js.src = '//connect.facebook.net/en_US/all.js'
d.getElementsByTagName( 'head' )[0].appendChild( js )
})
}
fb.checkAuth = function ( callback ) {
wait(
function(){ return !! fb.status },
function(){
fb.status = false
wait(
function(){ return !! fb.status },
function(){
fb.parseStatus( callback )
}
)
FB.getLoginStatus(function(response) {
fb.status = response
})
}
)
}
fb.login = function ( callback ) {
wait(
function(){ return !! fb.status },
function(){
FB.login(function( response ) {
fb.status = response
fb.parseStatus( callback )
})
}
)
}
fb.logout = function ( callback ) {
wait(
function(){ return !! fb.status },
function(){
FB.logout(function( response ) {
fb.status = response
fb.parseStatus( callback )
})
}
)
}
fb.parseStatus = function ( callback ) {
var status = ( fb.status.status == 'connected' ) ? fb.status.authResponse.userID : false
return callback( status )
}
}
// вспомогательные функции
function async ( callback ) {
setTimeout( callback, 0 )
}
function wait ( condition, callback ) {
var interval = setInterval( function () {
if ( condition() ) {
callback()
clearInterval( interval )
}
}, 100 )
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question