From baf3fc90e69b0fee1b54e2ab407555586ff4b907 Mon Sep 17 00:00:00 2001 From: John Bicket Date: Thu, 25 Jun 2015 16:58:28 -0700 Subject: [PATCH] SimpleAuthGoogleWebProvider.m: do not crash if account fields are not present in response objectForKey (which is what the assignment does below) cannot handle null values. While testing my profile came back as the following: info = { email = "jbicket@samsara.com"; "first_name" = John; image = "https://lh5.googleusercontent.com/-hTUulT9CemI/AAAAAAAAAAI/AAAAAAAAABs/o6pMlpQ0Lvk/photo.jpg"; "last_name" = Bicket; name = "John Bicket"; verified = 1; }; --- .../GoogleWeb/SimpleAuthGoogleWebProvider.m | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Pod/Providers/GoogleWeb/SimpleAuthGoogleWebProvider.m b/Pod/Providers/GoogleWeb/SimpleAuthGoogleWebProvider.m index 3bf070d..e0f882c 100644 --- a/Pod/Providers/GoogleWeb/SimpleAuthGoogleWebProvider.m +++ b/Pod/Providers/GoogleWeb/SimpleAuthGoogleWebProvider.m @@ -165,10 +165,6 @@ - (NSDictionary *)dictionaryWithAccount:(NSDictionary *)account dictionary[@"extra"] = @{ @"raw_info" : account }; - - // Location - NSString *location = account[@"location"][@"name"]; - // User info NSMutableDictionary *user = [NSMutableDictionary new]; if (account[@"email"]) { @@ -177,16 +173,20 @@ - (NSDictionary *)dictionaryWithAccount:(NSDictionary *)account user[@"name"] = account[@"name"]; user[@"first_name"] = account[@"given_name"]; user[@"last_name"] = account[@"family_name"]; - user[@"gender"] = account[@"gender"]; + if (account[@"gender"]) { + user[@"gender"] = account[@"gender"]; + } user[@"image"] = account[@"picture"]; - if (location) { - user[@"location"] = location; + if (account[@"location"] && account[@"location"][@"name"]) { + user[@"location"] = account[@"location"][@"name"]; } user[@"verified"] = account[@"verified_email"] ? @YES : @NO; - user[@"urls"] = @{ - @"Google +" : account[@"link"], - }; + if (account[@"link"]) { + user[@"urls"] = @{ + @"Google +" : account[@"link"], + }; + } dictionary[@"info"] = user;