From cd19e2b5ed4c8ad9da107b4b9f0add69aa8bd929 Mon Sep 17 00:00:00 2001 From: helge Date: Thu, 21 Jul 2005 09:51:19 +0000 Subject: [PATCH] added automatic redirect on login git-svn-id: http://svn.opengroupware.org/SOGo/trunk@865 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/Main/ChangeLog | 5 +++ SOGo/Main/README | 6 ++- SOGo/Main/SOGoRootPage.m | 86 +++++++++++++++++++++++++++++++++++++--- SOGo/Main/Version | 2 +- SOGo/Main/product.plist | 8 ++++ 5 files changed, 100 insertions(+), 7 deletions(-) diff --git a/SOGo/Main/ChangeLog b/SOGo/Main/ChangeLog index 9253a79b..4b5b564e 100644 --- a/SOGo/Main/ChangeLog +++ b/SOGo/Main/ChangeLog @@ -1,3 +1,8 @@ +2005-07-21 Helge Hess + + * SOGoRootPage.m: redirect authenticated users to their login page + (v0.9.37) + 2005-07-21 Marcus Mueller * homepage.js: fixed post to send an empty string instead of null - diff --git a/SOGo/Main/README b/SOGo/Main/README index a1972b4f..36c80043 100644 --- a/SOGo/Main/README +++ b/SOGo/Main/README @@ -30,10 +30,14 @@ SOGoInternetDetectQualifier Note: all header field names are lowercase Testing: -SOGoInternetDetectQualifier '"host = \"agenor.opengroupware.org\""' -AgenorProfileURL +AgenorProfileURL - URL - configure database location of the user profile eg: http://postgres:@agenor-db:5432/test/sogo_user_profile +SOGoDoNotRedirectRootPage - YES|NO +- do not redirect to home-folder for authenticated users but show the + root page (with the login name) + What it does ============ - provides locale support diff --git a/SOGo/Main/SOGoRootPage.m b/SOGo/Main/SOGoRootPage.m index 506856d2..788662f3 100644 --- a/SOGo/Main/SOGoRootPage.m +++ b/SOGo/Main/SOGoRootPage.m @@ -1,4 +1,23 @@ -// $Id$ +/* + Copyright (C) 2004-2005 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ #include @@ -9,14 +28,18 @@ @end +#include #include "common.h" @implementation SOGoRootPage -- (id)initWithContext:(id)_ctx { - if ((self = [super initWithContext:_ctx])) { - } - return self; +static BOOL doNotRedirect = NO; + ++ (void)initialize { + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + + if ((doNotRedirect = [ud boolForKey:@"SOGoDoNotRedirectRootPage"])) + NSLog(@"SOGoRootPage: home-page redirect is disabled."); } - (void)dealloc { @@ -52,6 +75,59 @@ return [self redirectToLocation:url]; } +- (id)defaultAction { + WOResponse *r; + NSString *login, *rhk; + id auth, user; + id home, base; + + if (doNotRedirect) + return self; + + /* + Note: ctx.activeUser is NOT set here. Don't know why, so we retrieve + the user from the authenticator. + */ + + auth = [[self clientObject] authenticatorInContext:[self context]]; + user = [auth userInContext:[self context]]; + login = [user login]; + + if ([login isEqualToString:@"anonymous"]) { + /* use root page for unauthenticated users */ + return self; + } + + /* check base */ + + base = [self application]; + rhk = [[[self context] request] requestHandlerKey]; + if (([rhk length] == 0) || ([base requestHandlerForKey:rhk] == nil)) { + base = [base lookupName:@"so" inContext:[self 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:[self 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 = [[self context] response]; + [r setStatus:302 /* moved */]; + [r setHeader:[home baseURLInContext:[self context]] forKey:@"location"]; + return r; +} + /* response generation */ - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { diff --git a/SOGo/Main/Version b/SOGo/Main/Version index b991595c..3dff6564 100644 --- a/SOGo/Main/Version +++ b/SOGo/Main/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=36 +SUBMINOR_VERSION:=37 # v0.9.32 requires libSOGo v0.9.57 # v0.9.24 requires libWEExtensions v4.5.67 diff --git a/SOGo/Main/product.plist b/SOGo/Main/product.plist index fb29d2e7..c0bc30bd 100644 --- a/SOGo/Main/product.plist +++ b/SOGo/Main/product.plist @@ -30,6 +30,14 @@ }; }; + SOGoRootPage = { + superclass = "SoComponent"; + protectedBy = "View"; + defaultRoles = { + "View" = "Authenticated"; + }; + }; + SOGoObject = { protectedBy = "View"; defaultAccess = "allow"; -- 2.39.5