Last active
July 12, 2018 19:09
-
-
Save etuchscherer/443f6aca7215775b885d81d1db051566 to your computer and use it in GitHub Desktop.
how we connect to facebook manually...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
facebookConnect: function (domId) { | |
var _this = this; | |
_this.get('controllers.facebook').fbLoginStatus().then(function (resp) { | |
if (resp === 'blocked_by_client') { | |
var $fbConnAction = $('#' + domId); | |
$fbConnAction.popover({ | |
placement: 'auto top', | |
trigger: 'manual', | |
title: '<strong>Unable to Connect to Facebook</strong>', | |
html: true, | |
content: 'A Facebook connection is required to continue, but cannot be established. Consider disabling browser plugins that might block Facebook Connect.' | |
}).popover('toggle'); | |
} else { | |
_this.set('controllers.facebook.fromSPV', true); | |
if (_this.get('controllers.facebook.connectToMismatch')) { | |
_this.transitionToRoute('classphotos.mismatch'); | |
} else if (_this.get('controllers.facebook.fbConnected')) { | |
// console.log("fbConnected"); | |
_this.get('controllers.facebook').setBypassParam(true); | |
if (_this.get('controllers.facebook.isCMAuthorized')) { | |
// console.log("isCMAuthed"); | |
_this.get('controllers.facebook').cmMemberTieFlow(); | |
} else { | |
// console.log("NOT cmAuthed."); | |
_this.get('controllers.facebook').loginToCMWithFB(); | |
} | |
} else { | |
// we test if the user is logged in via classmates' system | |
if (_this.get('isVisitor')) { | |
// if visitor... and not connected to facebook -> then connect to facebook | |
window.location.href = globals.linkBuilder.facebookLoginUrl({ | |
redirectTo: globals.linkBuilder.links.classphotosUrl + '?connectBypass=true' | |
}); | |
} else { | |
// if user... and not connected to facebook -> connect to facebook, when successful | |
// tie the two accounts together. | |
window.location.href = globals.linkBuilder.facebookLoginUrl({ | |
redirectTo: globals.linkBuilder.links.classphotosUrl + "?connectBypass=true&createTie=true" | |
}); | |
} | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
linkBuilder.facebookLoginUrl = function(_args) { | |
_args = _args || {}, | |
permissions = _args.permissions || envConf.facebook.permissions, | |
redirectTo = _args.redirectTo || linkBuilder.links.classphotosUrl + '?connectBypass=true', | |
cancelUrl = _args.cancelUrl || linkBuilder.links.classphotosConnectUrl, | |
clientId = _args.clientId || linkBuilder.facebook.facebookAppID; | |
return 'https://www.facebook.com/'+envConf.facebook.facebookVersion+'/dialog/oauth?client_id=' + clientId + | |
'&redirect_uri=' + encodeURIComponent(redirectTo) + '&scope=' + | |
permissions + '&cancel_url=' + encodeURIComponent(cancelUrl); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment