// $Id$ #include @interface SOGoRootPage : SoComponent { NSString *userName; } @end #include "common.h" @implementation SOGoRootPage - (id)initWithContext:(id)_ctx { if ((self = [super initWithContext:_ctx])) { } return self; } - (void)dealloc { [self->userName release]; [super dealloc]; } /* accessors */ - (void)setUserName:(NSString *)_value { ASSIGNCOPY(self->userName, _value); } - (NSString *)userName { return self->userName; } /* actions */ - (id)connectAction { NSString *url; [self takeFormValuesForKeys:@"userName", nil]; if ([[self userName] length] == 0) return nil; url = [@"/" stringByAppendingString:[[self userName] stringByEscapingURL]]; if (![url hasSuffix:@"/"]) url = [url stringByAppendingString:@"/"]; url = [[self context] urlWithRequestHandlerKey:@"so" path:url queryString:nil]; return [self redirectToLocation:url]; } /* 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; } [super appendToResponse:_response inContext:_ctx]; } @end /* SOGoRootPage */