2
Copyright (C) 2000-2005 SKYRIX Software AG
4
This file is part of SOPE.
6
SOPE is free software; you can redistribute it and/or modify it under
7
the terms of the GNU Lesser General Public License as published by the
8
Free Software Foundation; either version 2, or (at your option) any
11
SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14
License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with SOPE; see the file COPYING. If not, write to the
18
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22
#include <NGObjWeb/WOComponent.h>
23
#include <NGObjWeb/WODirectAction.h>
25
@interface iCalPortalWelcomePage : WOComponent
31
@interface iCalPortalWelcomeAction : WODirectAction
34
#include "iCalPortalUser.h"
35
#include "iCalPortalDatabase.h"
38
@implementation iCalPortalWelcomePage
48
- (BOOL)isSessionProtectedPage {
59
@end /* iCalPortalWelcomePage */
61
@implementation iCalPortalWelcomeAction
63
- (BOOL)redirectOnLogin {
68
NSString *login, *pwd;
69
iCalPortalDatabase *db;
72
db = [(id)[WOApplication application] database];
74
login = [[self request] formValueForKey:@"user"];
75
pwd = [[self request] formValueForKey:@"pwd"];
77
if (![db isLoginNameValid:login]) {
78
[self logWithFormat:@"tried an invalid login: '%@'", login];
79
return [self indexPage];
82
if ((user = [db userWithName:login password:pwd]) == nil) {
83
[self logWithFormat:@"login failed: '%@'", login];
84
return [self indexPage];
87
[self logWithFormat:@"user %@ is logged in.", login];
88
[[self session] setObject:user forKey:@"user"];
94
if ((lang = [[self request] formValueForKey:@"language"])) {
95
NSMutableArray *langs;
97
if ([lang isEqualToString:@"en"])
99
else if ([lang isEqualToString:@"de"])
102
langs = [NSMutableArray arrayWithCapacity:16];
103
[langs addObject:lang];
104
[langs addObject:[[self session] languages]];
105
[[self session] setLanguages:langs];
109
/* deliver login result */
111
if ([self redirectOnLogin]) {
112
/* make a redirect on login (better for deployment) ... */
117
qd = [NSDictionary dictionaryWithObject:[[self session] sessionID]
118
forKey:WORequestValueSessionID];
120
homeURL = [[[WOApplication application] context]
121
directActionURLForActionNamed:@"home"
124
r = [WOResponse responseWithRequest:[self request]];
126
[r setHeader:homeURL forKey:@"location"];
130
/* better for development */
131
return [[self pageWithName:@"iCalPortalHomePage"] performPage];
135
@end /* iCalPortalWelcomeAction */