0

So a PFUser will log in the traditional way, using an email and password. When they sign up, I set the userName to be equal to the email address. When a user signs in, they use their email.

This was working great until I added a "connect to facebook" button where I call the following:

[PFFacebookUtils linkUserInBackground:[PFUser currentUser] withReadPermissions:@[@"public_profile", @"user_friends"] block:^(BOOL succeeded, NSError *error) {
                if (succeeded) {
                    NSLog(@"Woohoo, user is linked with Facebook!");

                    [self.tableView reloadData];
                }
            }];

The problem is, when this succeeds, my username has changed to a long string of random characters. Which means if I log out, I can no longer log back in because the email no longer matches the username.

I am using parse-server on Heroku. I won't post any cloud code because this didn't start happening until I implemented Facebook oauth.

mnearents
  • 646
  • 1
  • 6
  • 31
  • Are you saving their email in the parse username field or the parse email field? – Max Phillips Mar 12 '16 at 00:27
  • Both, I set both fields equal to their email address. I didn't want to deal with having a username AND an email address. – mnearents Mar 12 '16 at 00:28
  • So you have two copies of the email address, one in username, one in email? If that's the case you just need to change your Parse login to login with email instead of login with username. It's exactly the same thing except your pointing the login to the email field instead of the username field. – Max Phillips Mar 12 '16 at 00:28
  • That's what I do. I pass their email address to `PFUser logInWithUsernameInBackground` – mnearents Mar 12 '16 at 00:34

1 Answers1

0

You have to query for the user using their email. Once you've returned the user object get the username by using user.username. Once you have their username you can log them in with loginWithUsernameInBackground. It seems like the long way around an easy thing but that's how you do it.

Max Phillips
  • 6,991
  • 9
  • 44
  • 71