From 1ed3955bd0b01b5cb1419c07596c457bb7f3a684 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 12 Sep 2007 13:01:17 +0000 Subject: [PATCH] Monotone-Parent: 9ef1fb2c66953b8ada0d55d0eec183621a71ebab Monotone-Revision: dc5f7b2c31d9e41fc7a1cb9e62c39060dca4d576 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-09-12T13:01:17 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 8 ++++ UI/MainUI/SOGoRootPage.m | 96 +++++++--------------------------------- 2 files changed, 24 insertions(+), 80 deletions(-) diff --git a/ChangeLog b/ChangeLog index 53a2270d6..3556ea464 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-09-12 Wolfgang Sourdeau + + * UI/MainUI/SOGoRootPage.m ([SOGoRootPage -defaultAction]): test + whether the user is logged in and if so, redirect to his/her + homepage. + ([SOGoRootPage -appendToResponse:inContext:]): removed useless + method. + 2007-09-11 Wolfgang Sourdeau * SoObjects/SOGo/SOGoFolder.m ([SOGoFolder diff --git a/UI/MainUI/SOGoRootPage.m b/UI/MainUI/SOGoRootPage.m index d4bdc2070..f0323e638 100644 --- a/UI/MainUI/SOGoRootPage.m +++ b/UI/MainUI/SOGoRootPage.m @@ -83,88 +83,24 @@ return response; } -// - (id ) defaultAction -// { -// WOResponse *r; -// NSString *login, *rhk; -// SOGoWebAuthenticator *auth; -// SOGoUser *user; -// SOGoUserFolder *home; -// WOApplication *base; +- (id ) defaultAction +{ + id response; + NSString *login, *oldLocation; -// /* -// Note: ctx.activeUser is NOT set here. Don't know why, so we retrieve -// the user from the authenticator. -// */ - -// auth = [[self clientObject] authenticatorInContext: context]; -// user = [auth userInContext: context]; -// login = [user login]; + login = [[context activeUser] login]; + if ([login isEqualToString: @"anonymous"]) + response = self; + else + { + oldLocation = [[self clientObject] baseURLInContext: context]; + response + = [self redirectToLocation: [NSString stringWithFormat: @"%@/%@", + oldLocation, login]]; + } -// if ([login isEqualToString:@"anonymous"]) { -// /* use root page for unauthenticated users */ -// return self; -// } - -// /* check base */ - -// base = [self application]; -// rhk = [[context request] requestHandlerKey]; -// if (([rhk length] == 0) || ([base requestHandlerForKey:rhk] == nil)) { -// base = [base lookupName: @"so" inContext: context acquire: NO]; - -// if (![base isNotNull] || [base isKindOfClass:[NSException class]]) { -// /* use root page if home could not be found */ -// [self errorWithFormat:@"Did not find 'so' request handler!"]; -// return self; -// } -// } - -// /* lookup home-page */ - -// home = [base lookupName: login inContext: context acquire: NO]; -// if (![home isNotNull] || [home isKindOfClass:[NSException class]]) { -// /* use root page if home could not be found */ -// return self; -// } - -// /* redirect to home-page */ - -// r = [context response]; -// [r setStatus: 302 /* moved */]; -// [r setHeader: [home baseURLInContext: context] -// forKey: @"location"]; - -// return r; -// } - -/* response generation */ - -// - (void) appendToResponse: (WOResponse *) response -// inContext: (WOContext *) ctx -// { -// NSString *rhk; - -// // TODO: we might also want to look into the HTTP basic-auth to redirect to -// // the login URL! - -// rhk = [[ctx request] requestHandlerKey]; -// if ([rhk length] == 0 -// || [[self application] requestHandlerForKey: rhk] == nil) -// { -// /* a small hack to redirect to a valid URL */ -// NSString *url; - -// url = [ctx urlWithRequestHandlerKey: @"so" path: @"/" queryString: nil]; -// [response setStatus: 302 /* moved */]; -// [response setHeader: url forKey: @"location"]; -// [self logWithFormat: @"URL: %@", url]; -// return; -// } - -// [response setHeader: @"text/html" forKey: @"content-type"]; -// [super appendToResponse: response inContext: ctx]; -// } + return response; +} - (BOOL) isPublicInContext: (WOContext *) localContext {