nate-strauser / wework

We Work Meteor, a job board and developer directory for Meteor specific work
https://www.weworkmeteor.com
MIT License
288 stars 145 forks source link

Facebook Login Admin Issue #90

Closed ritchieng closed 8 years ago

ritchieng commented 8 years ago

Hi,

If a user were to use Facebook login, their emails won't be available in the admin panel.

As a result:

  1. Admin panel won't show results of users (they'll show the number but no details)
  2. You cannot send verification emails.

Any fix to this? Really appreciate it.

Thanks!

ritchieng commented 8 years ago

Found a fix.

If anyone's experiencing the same issue do the following in your server/accounts.js:

Accounts.onCreateUser(function(options, user) {
  if (options.profile)
    user.profile = options.profile;

  var email = getUserEmail(user);
  if(email){
    user.emailHash = CryptoJS.MD5(email.trim().toLowerCase()).toString();
  }

    if (!user.emails) {
        user.emails = [{address: user.services.facebook.email, verified: false}];
    }

  return user;
});
nate-strauser commented 8 years ago

looks good - except, it should likely be

`` if(!user.emails && user.services && user.services.facebook && user.services.facebook.email) user.emails = user.services.facebook.email


you should only pull in the facebook email if it exists

without this, signing up up with non-facebook oauth that doesnt have email
address will cause user.services.facebook to be undefined and throw an error

On Mon, Mar 7, 2016 at 4:47 PM, ritchieng <notifications@github.com> wrote:

> Closed #90 <https://github.com/nate-strauser/wework/issues/90>.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/nate-strauser/wework/issues/90#event-580828804>.
>
ritchieng commented 8 years ago

Thanks. I tried your fix and it doesn't work though, it gave an internal server error when signing in.

nate-strauser commented 8 years ago

braces {} are optional if its just 1 line after the 'if(...)' - totally fine to always use braces though

On Mon, Mar 7, 2016 at 4:57 PM, ritchieng notifications@github.com wrote:

You're really good, I'm still new at this. Haha.

You need a {} right? Like this:

if(!user.emails && user.services && user.services.facebook && user.services.facebook.email) { user.emails = user.services.facebook.email }

— Reply to this email directly or view it on GitHub https://github.com/nate-strauser/wework/issues/90#issuecomment-193473666 .