From 04ce8d10665ca734fefcbb8cd5c217add4ab614b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Garc=C3=ADa=20S=C3=A1ez?= Date: Wed, 20 May 2015 12:31:25 +0200 Subject: [PATCH] Avoid cache entries with uid@domain@domain prefix Depend of the current workflow this paths are reached with username as uid and sometimes as uid@domain. So in multidomain environments only append @domain when needed. Conflicts: SoObjects/SOGo/SOGoUserManager.m --- SoObjects/SOGo/SOGoUserManager.m | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index 52f7167ad..be7d21979 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -495,11 +495,11 @@ static Class NSNullK; dd = [SOGoSystemDefaults sharedSystemDefaults]; - // We check for cached passwords. If the entry is cached, we - // check this immediately. If not, we'll go directly at the - // authentication source and try to validate there, then cache it. - if (*_domain != nil) - username = [NSString stringWithFormat: @"%@@%@", _login, *_domain]; + if (*_domain) + { + if ([_login rangeOfString: @"@"].location == NSNotFound) + username = [NSString stringWithFormat: @"%@@%@", _login, *_domain]; + } else { NSRange r; @@ -532,13 +532,10 @@ static Class NSNullK; } } - failedCount = [[SOGoCache sharedCache] failedCountForLogin: username]; - - // // We check the fail count per user in memcache (per server). If the // fail count reaches X in Y minutes, we deny immediately the // authentications for Z minutes - // + failedCount = [[SOGoCache sharedCache] failedCountForLogin: username]; if (failedCount) { unsigned int current_time, start_time, delta, block_time; @@ -564,7 +561,9 @@ static Class NSNullK; } } - + // We check for cached passwords. If the entry is cached, we + // check this immediately. If not, we'll go directly at the + // authentication source and try to validate there, then cache it. jsonUser = [[SOGoCache sharedCache] userAttributesForLogin: username]; currentUser = [jsonUser objectFromJSONString]; dictPassword = [currentUser objectForKey: @"password"];