Skip to content

Commit

Permalink
(fix) avoid double-appending domain in cache (fixes #3614)
Browse files Browse the repository at this point in the history
  • Loading branch information
extrafu committed Apr 12, 2016
1 parent c091c05 commit fc86e60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions SoObjects/SOGo/SOGoUserManager.m
Expand Up @@ -410,7 +410,7 @@ - (NSString *) getUIDForEmail: (NSString *) email
{
NSDictionary *info;
SOGoSystemDefaults *sd;
NSString *uid, *domain;
NSString *uid, *domain, *suffix;

info = [self contactInfosForUserWithUIDorEmail: email];
uid = [info objectForKey: @"c_uid"];
Expand All @@ -420,7 +420,11 @@ - (NSString *) getUIDForEmail: (NSString *) email
&& ![[info objectForKey: @"DomainLessLogin"] boolValue])
{
domain = [info objectForKey: @"c_domain"];
uid = [NSString stringWithFormat: @"%@@%@", uid, domain];
suffix = [NSString stringWithFormat: @"@%@", domain];

// Don't add @domain suffix if it's already there
if (![uid hasSuffix: suffix])
uid = [NSString stringWithFormat: @"%@%@", uid, suffix];
}

return uid;
Expand Down Expand Up @@ -1051,8 +1055,15 @@ - (NSDictionary *) contactInfosForUserWithUIDorEmail: (NSString *) uid
// multi-domain environments authenticating only with the UIDFieldName
if ([sd enableDomainBasedUID] && !domain)
{
cacheUid = [NSString stringWithFormat: @"%@@%@", cacheUid, [currentUser objectForKey: @"c_domain"]];
[currentUser setObject: [NSNumber numberWithBool: YES] forKey: @"DomainLessLogin"];
NSString *suffix;

suffix = [NSString stringWithFormat: @"@%@", [currentUser objectForKey: @"c_domain"]];

if (![cacheUid hasSuffix: suffix])
{
cacheUid = [NSString stringWithFormat: @"%@%@", cacheUid, suffix];
[currentUser setObject: [NSNumber numberWithBool: YES] forKey: @"DomainLessLogin"];
}
}

[self _retainUser: currentUser withLogin: cacheUid];
Expand Down
2 changes: 1 addition & 1 deletion UI/MainUI/SOGoRootPage.m
Expand Up @@ -231,7 +231,7 @@ - (WOResponse *) _responseWithLDAPPolicyError: (int) error
// has all the logic for this, so lets use it.
if ([domain isNotNull])
{
username = [[SOGoUserManager sharedUserManager] getUIDForEmail: username];
username = [[SOGoUserManager sharedUserManager] getUIDForEmail: username];
}

authCookie = [auth cookieWithUsername: username
Expand Down

0 comments on commit fc86e60

Please sign in to comment.