From 0655e9d76e085159d2d54976caaef7250cce282c Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Tue, 5 Jul 2016 22:25:01 -0400 Subject: [PATCH] (fix) make sure to handle nil vs. NSNull values correctly --- SoObjects/SOGo/SOGoUserManager.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index 2463b5a18..b92c0fdac 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -610,6 +610,9 @@ static Class NSNullK; jsonUser = [[SOGoCache sharedCache] userAttributesForLogin: username]; currentUser = [jsonUser objectFromJSONString]; + if ([currentUser isKindOfClass: NSNullK]) + currentUser = nil; + // // If we are using multidomain and the UIDFieldName is not part of the email address // we must bind without the domain part since internally, SOGo will use @@ -623,7 +626,7 @@ static Class NSNullK; // and authenticates with "foo", using bindFields = (uid, mail) and SOGoEnableDomainBasedUID = YES; // Otherwise, -_sourceCheckLogin:... would have failed because SOGo would try to bind using: foo@example.com // - if ([[currentUser objectForKey: @"DomainLessLogin"] boolValue]) + if (currentUser && [[currentUser objectForKey: @"DomainLessLogin"] boolValue]) { NSRange r; @@ -631,7 +634,7 @@ static Class NSNullK; _login = [_login substringToIndex: r.location]; } - dictPassword = [currentUser objectForKey: @"password"]; + dictPassword = (currentUser ? [currentUser objectForKey: @"password"] : nil); if (useCache && currentUser && dictPassword) { checkOK = ([dictPassword isEqualToString: [_pwd asSHA1String]]); @@ -723,6 +726,9 @@ static Class NSNullK; jsonUser = [[SOGoCache sharedCache] userAttributesForLogin: login]; currentUser = [jsonUser objectFromJSONString]; + if ([currentUser isKindOfClass: NSNullK]) + currentUser = nil; + if ([self _sourceChangePasswordForLogin: login inDomain: domain oldPassword: oldPassword