Make Facebook login only happen when user explicitly clicks to do so

This commit is contained in:
Scott Erickson 2015-12-11 14:47:42 -08:00
parent 71bca28148
commit 703671940f
3 changed files with 22 additions and 8 deletions

View file

@ -15,19 +15,31 @@ userPropsToSave =
module.exports = FacebookHandler = class FacebookHandler extends CocoClass
subscriptions:
'auth:logged-in-with-facebook': 'onFacebookLoggedIn'
loggedIn: false
onFacebookLoggedIn: (e) ->
# user is logged in also when the page first loads, so check to see
# if we really need to do the lookup
return if not me
doIt = false
@loggedIn = false
@authResponse = e.response.authResponse
for fbProp, userProp of userPropsToSave
unless me.get(userProp)
doIt = true
@loggedIn = true
break
FB.api('/me', @onReceiveMeInfo) if doIt
if @waitingForLogin and @loggedIn
@fetchMeForLogin
loginThroughFacebook: ->
if @loggedIn
@fetchMeForLogin()
else
FB.login()
@waitingForLogin = true
fetchMeForLogin: ->
FB.api('/me', @onReceiveMeInfo)
onReceiveMeInfo: (r) =>
unless r.email

View file

@ -88,11 +88,9 @@
// btn.btn.btn-sm.github-login-button#github-login-button
// img(src="/images/pages/modal/auth/github_icon.png")
// | GitHub
.btn.btn-primary.btn-lg.btn-illustrated.network-login
#facebook-login-btn.btn.btn-primary.btn-lg.btn-illustrated.network-login
img.network-logo(src="/images/pages/community/logo_facebook.png", draggable="false")
span.sign-in-blurb(data-i18n="login.sign_in_with_facebook") Sign in with Facebook
.facebook-login-wrapper
.fb-login-button(data-show-faces="false", data-width="200", data-max-rows="1", data-scope="email")
.btn.btn-danger.btn-lg.btn-illustrated.network-login
img.network-logo(src="/images/pages/community/logo_g+.png", draggable="false")
span.sign-in-blurb(data-i18n="login.sign_in_with_gplus") Sign in with G+

View file

@ -19,6 +19,7 @@ module.exports = class AuthModal extends ModalView
'keyup #name': 'onNameChange'
'click #gplus-login-button': 'onClickGPlusLogin'
'click #close-modal': 'hide'
'click #facebook-login-btn': 'onClickFacebookLoginButton'
subscriptions:
'errors:server-error': 'onServerError'
@ -158,6 +159,9 @@ module.exports = class AuthModal extends ModalView
@$el.find('.modal-body:visible').empty().append(el)
@$el.find('.modal-footer').remove()
onClickFacebookLoginButton: ->
application.facebookHandler.loginThroughFacebook()
onHidden: ->
super()
@playSound 'game-menu-close'