diff --git a/ChangeLog b/ChangeLog index 006b62f20..1ea3a5883 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2010-02-18 Wolfgang Sourdeau + * UI/MainUI/SOGoRootPage.m (-_casDefaultAction): when the local + cache has expired, we create a "cas-location" cookie before + redirecting to the CAS login page and we redirect the user back to + that page when the login has been completed. This way, the + event creation window or any AJAX request would seamlessly restart + where "interrupted" by the login process. + * SoObjects/Appointments/SOGoCalendarComponent.m (-sendEMailUsingTemplateNamed:forObject:previousObject:toAttendees:): added a few headers to the ical attachment that could help diff --git a/UI/MainUI/SOGoRootPage.m b/UI/MainUI/SOGoRootPage.m index af50c4846..4f0823898 100644 --- a/UI/MainUI/SOGoRootPage.m +++ b/UI/MainUI/SOGoRootPage.m @@ -19,8 +19,10 @@ 02111-1307, USA. */ +#import #import #import +#import #import #import @@ -31,6 +33,7 @@ #import #import +#import #import #import #import @@ -81,6 +84,27 @@ return authCookie; } +- (WOCookie *) _casLocationCookie: (BOOL) cookieReset +{ + WOCookie *locationCookie; + NSString *appName; + WORequest *rq; + NSCalendarDate *date; + + rq = [context request]; + locationCookie = [WOCookie cookieWithName: @"cas-location" value: [rq uri]]; + appName = [rq applicationName]; + [locationCookie setPath: [NSString stringWithFormat: @"/%@/", appName]]; + if (cookieReset) + { + date = [NSCalendarDate calendarDate]; + [date setTimeZone: [NSTimeZone timeZoneWithAbbreviation: @"GMT"]]; + [locationCookie setExpires: [date yesterday]]; + } + + return locationCookie; +} + /* actions */ - (id ) connectAction { @@ -161,16 +185,21 @@ NSString *login, *newLocation, *oldLocation, *ticket; SOGoCASSession *casSession; SOGoWebAuthenticator *auth; - WOCookie *casCookie; + WOCookie *casCookie, *casLocationCookie; + WORequest *rq; casCookie = nil; + casLocationCookie = nil; + + newLocation = nil; login = [[context activeUser] login]; if ([login isEqualToString: @"anonymous"]) login = nil; if (!login) { - ticket = [[context request] formValueForKey: @"ticket"]; + rq = [context request]; + ticket = [rq formValueForKey: @"ticket"]; if ([ticket length]) { casSession = [SOGoCASSession CASSessionWithTicket: ticket]; @@ -183,22 +212,40 @@ andPassword: [casSession identifier] forAuthenticator: auth]; [casSession updateCache]; + newLocation = [rq cookieValueForKey: @"cas-location"]; + /* login callback, we expire the "cas-location" cookie, created + below */ + casLocationCookie = [self _casLocationCookie: YES]; } } } + else + ticket = nil; if (login) { - oldLocation = [[self clientObject] baseURLInContext: context]; - newLocation = [NSString stringWithFormat: @"%@%@", - oldLocation, [login stringByEscapingURL]]; + /* We redirect the user to his "homepage" when newLocation could not be + deduced from the "cas-location" cookie and the current action is not a + login callback (ticket != nil). */ + if (!newLocation || !ticket) + { + oldLocation = [[self clientObject] baseURLInContext: context]; + newLocation = [NSString stringWithFormat: @"%@%@", + oldLocation, [login stringByEscapingURL]]; + } } else - newLocation = [SOGoCASSession CASURLWithAction: @"login" - andParameters: [self _casRedirectKeys]]; + { + newLocation + = [SOGoCASSession CASURLWithAction: @"login" + andParameters: [self _casRedirectKeys]]; + casLocationCookie = [self _casLocationCookie: NO]; + } response = [self redirectToLocation: newLocation]; if (casCookie) [response addCookie: casCookie]; + if (casLocationCookie) + [response addCookie: casLocationCookie]; return response; }