Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Facebook - dictionaryWithRemoteAccount have no checks for nil in optional values #59

Closed
plushcube opened this issue May 7, 2014 · 6 comments

Comments

@plushcube
Copy link

For example, let's see at User Info block:

// User info
NSMutableDictionary *user = [NSMutableDictionary new];
user[@"nickname"] = remoteAccount[@"username"];
user[@"email"] = remoteAccount[@"email"];
user[@"name"] = remoteAccount[@"name"];
user[@"first_name"] = remoteAccount[@"first_name"];
user[@"last_name"] = remoteAccount[@"last_name"];
user[@"image"] = avatar;
if (location) {
    user[@"location"] = location;
}
user[@"verified"] = remoteAccount[@"verified"];
user[@"urls"] = @{
    @"Facebook" : remoteAccount[@"link"],
};

But my own profile has no Username and my app will crash when I try to authorize via Facebook.

@LordParsley
Copy link

Also encountered this issue. Recommend next version uses [user setValue:remoteAccount[@"username"] forKey:@"nickname" ]; etc. since nil will just remove the key, and we can check NSDictionary @"whatever" for nil in response if we're going to use any particular parameter.

@mergesort
Copy link

I was just coming here to post this issue, just encountered it in production, hadn't seen it happening before.

@calebd calebd closed this as completed in 331a08a Sep 5, 2014
@mergesort
Copy link

@calebd I don't think 331a08a the correct fix for this. The username is an optional field which if it is present, I would like to have it. If it is not available, it should be blank or nil. I would add a check around the username to make sure it's not nil, instead of just removing the field, because the nickname is something that people do use.

@calebd
Copy link
Owner

calebd commented Sep 5, 2014

@mergesort It wasn't what I wanted to do originally, but after looking into it I couldn't find the username field documented by Facebook on user responses at all. Also, my Facebook user has a username but that never came down from the authorization API. I can put it back for sure if you are seeing a different behavior.

@markkrenek
Copy link
Contributor

username is no longer available in the Facebook API, starting in 2.0.

@mergesort
Copy link

@markkrenek @calebd Ah, my mistake. I wasn't aware of the changes since they haven't fully deprecated it yet (it's still working for apps created before April 30th, 2014). Carry on then...

@calebd calebd reopened this Sep 16, 2014
@calebd calebd closed this as completed Sep 16, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants