From 22196e0054f9040ba33557e693701afc9ee16ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20S=C3=A1ez?= Date: Wed, 25 Feb 2015 12:01:31 +0100 Subject: [PATCH] Fix change password with DomainBasedUID When users use full domain to login (SOGoEnableDomainBasedUID) the user attributes in the cache were not being properly updated because in this case the key is `uid@domain` instead of just `uid`. --- SoObjects/SOGo/SOGoUserManager.m | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index d8e09ba6c..4d6a5b911 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -595,10 +595,11 @@ static Class NSNullK; newPassword: (NSString *) newPassword perr: (SOGoPasswordPolicyError *) perr { - NSString *jsonUser; + NSString *jsonUser, *userLogin; NSMutableDictionary *currentUser; BOOL didChange; - + SOGoSystemDefaults *sd; + jsonUser = [[SOGoCache sharedCache] userAttributesForLogin: login]; currentUser = [jsonUser objectFromJSONString]; @@ -611,9 +612,7 @@ static Class NSNullK; didChange = YES; if (!currentUser) - { - currentUser = [NSMutableDictionary dictionary]; - } + currentUser = [NSMutableDictionary dictionary]; // It's important to cache the password here as we might have cached the // user's entry in -contactInfosForUserWithUIDorEmail: and if we don't @@ -621,9 +620,13 @@ static Class NSNullK; // cached for the user unless its entry expires from memcached's // internal cache. [currentUser setObject: [newPassword asSHA1String] forKey: @"password"]; - [[SOGoCache sharedCache] - setUserAttributes: [currentUser jsonRepresentation] - forLogin: login]; + sd = [SOGoSystemDefaults sharedSystemDefaults]; + if ([sd enableDomainBasedUID]) + userLogin = [NSString stringWithFormat: @"%@@%@", login, domain]; + else + userLogin = login; + [[SOGoCache sharedCache] setUserAttributes: [currentUser jsonRepresentation] + forLogin: userLogin]; } else didChange = NO;