diff --git a/NEWS b/NEWS index fab78c558..4ddf40757 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ Bug fixes - Fixed several sync issues on environments with multiple users (Zentyal) - Folders from other users will no longer appear on your Outlook (Zentyal) - Use right auth in multidomain environments in contacts and calendar from Outlook (Zentyal) + - Session fix when SOGoEnableDomainBasedUID is enabled but logins are domain-less 2.3.1 (2015-07-23) ------------------ diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index 783e16b26..9765076fd 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -778,7 +778,10 @@ static Class NSNullK; NSRange r; r = [theUID rangeOfString: [NSString stringWithFormat: @"@%@", theDomain]]; - theUID = [theUID substringToIndex: r.location]; + + // We check if the range is ok here since we could be using DomainLessLogin + if (r.location != NSNotFound) + theUID = [theUID substringToIndex: r.location]; } sogoSources = [[self authenticationSourceIDsInDomain: theDomain] objectEnumerator]; diff --git a/UI/MainUI/SOGoRootPage.m b/UI/MainUI/SOGoRootPage.m index 3001e7cd6..289e816e6 100644 --- a/UI/MainUI/SOGoRootPage.m +++ b/UI/MainUI/SOGoRootPage.m @@ -183,7 +183,6 @@ SOGoWebAuthenticator *auth; SOGoAppointmentFolders *calendars; SOGoUserDefaults *ud; - SOGoSystemDefaults *sd; SOGoUser *loggedInUser; NSDictionary *params; NSString *username, *password, *language, *domain, *remoteHost; @@ -226,13 +225,15 @@ response = [self responseWithStatus: 200 andJSONRepresentation: json]; - + + // We get the proper username for cookie creation. If we are using a multidomain + // environment with SOGoEnableDomainBasedUID, we could have to append the domain + // to the username. Also when SOGoEnableDomainBasedUID is enabled, we could be in + // the DomainLessLogin situation, so we would NOT add the domain. -getUIDForEmail + // has all the logic for this, so lets use it. if ([domain isNotNull]) { - sd = [SOGoSystemDefaults sharedSystemDefaults]; - if ([sd enableDomainBasedUID] && - [username rangeOfString: @"@"].location == NSNotFound) - username = [NSString stringWithFormat: @"%@@%@", username, domain]; + username = [[SOGoUserManager sharedUserManager] getUIDForEmail: username]; } authCookie = [auth cookieWithUsername: username