2006-06-15 21:34:10 +02:00
|
|
|
/*
|
2010-03-15 00:07:42 +01:00
|
|
|
|
|
|
|
Copyright (C) 2006-2010 Inverse inc.
|
2006-06-15 21:34:10 +02:00
|
|
|
Copyright (C) 2004-2005 SKYRIX Software AG
|
|
|
|
|
2010-03-15 00:07:42 +01:00
|
|
|
This file is part of SOGo.
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2010-03-15 00:07:42 +01:00
|
|
|
SOGo is free software; you can redistribute it and/or modify it under
|
2006-06-15 21:34:10 +02:00
|
|
|
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.
|
|
|
|
|
2010-03-15 00:07:42 +01:00
|
|
|
SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
2006-06-15 21:34:10 +02:00
|
|
|
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
|
2010-03-15 00:07:42 +01:00
|
|
|
License along with SOGo; see the file COPYING. If not, write to the
|
2006-06-15 21:34:10 +02:00
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2010-02-18 22:39:25 +01:00
|
|
|
#import <Foundation/NSCalendarDate.h>
|
2010-01-28 22:42:03 +01:00
|
|
|
#import <Foundation/NSDictionary.h>
|
2007-12-13 20:26:47 +01:00
|
|
|
#import <Foundation/NSException.h>
|
2010-02-18 22:39:25 +01:00
|
|
|
#import <Foundation/NSTimeZone.h>
|
2010-01-28 22:42:03 +01:00
|
|
|
#import <Foundation/NSURL.h>
|
2010-03-08 16:18:05 +01:00
|
|
|
#import <Foundation/NSValue.h>
|
2007-12-13 20:26:47 +01:00
|
|
|
|
2010-01-28 22:42:03 +01:00
|
|
|
#import <NGObjWeb/NSException+HTTP.h>
|
2007-08-06 16:06:27 +02:00
|
|
|
#import <NGObjWeb/WOApplication.h>
|
|
|
|
#import <NGObjWeb/WOContext.h>
|
2007-09-04 17:00:44 +02:00
|
|
|
#import <NGObjWeb/WOCookie.h>
|
2007-08-06 16:06:27 +02:00
|
|
|
#import <NGObjWeb/WORequest.h>
|
|
|
|
#import <NGObjWeb/WOResponse.h>
|
2007-12-05 22:05:04 +01:00
|
|
|
|
2007-09-07 00:21:16 +02:00
|
|
|
#import <NGExtensions/NGBase64Coding.h>
|
2010-02-18 22:39:25 +01:00
|
|
|
#import <NGExtensions/NSCalendarDate+misc.h>
|
2007-08-06 16:06:27 +02:00
|
|
|
#import <NGExtensions/NSNull+misc.h>
|
|
|
|
#import <NGExtensions/NSString+misc.h>
|
2007-09-04 17:00:44 +02:00
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2010-01-28 22:42:03 +01:00
|
|
|
#import <SOGo/NSDictionary+Utilities.h>
|
2010-03-08 16:18:05 +01:00
|
|
|
#import <SOGo/NSDictionary+BSJSONAdditions.h>
|
2010-01-28 22:42:03 +01:00
|
|
|
#import <SOGo/SOGoCache.h>
|
|
|
|
#import <SOGo/SOGoCASSession.h>
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <SOGo/SOGoDomainDefaults.h>
|
|
|
|
#import <SOGo/SOGoSystemDefaults.h>
|
|
|
|
#import <SOGo/SOGoUser.h>
|
2010-03-08 16:18:05 +01:00
|
|
|
#import <SOGo/SOGoUserManager.h>
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <SOGo/SOGoWebAuthenticator.h>
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2010-03-08 16:18:05 +01:00
|
|
|
#import <SOGo/SOGoConstants.h>
|
|
|
|
|
2007-09-04 17:00:44 +02:00
|
|
|
#import "SOGoRootPage.h"
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-12-13 20:26:47 +01:00
|
|
|
@interface SOGoRootPage (crashAdditions)
|
|
|
|
|
|
|
|
- (void) segfault;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
@implementation SOGoRootPage
|
|
|
|
|
|
|
|
/* accessors */
|
|
|
|
|
2007-09-07 00:21:16 +02:00
|
|
|
- (NSString *) connectURL
|
|
|
|
{
|
2009-11-10 22:39:40 +01:00
|
|
|
return [NSString stringWithFormat: @"%@/connect", [self applicationPath]];
|
2007-09-07 00:21:16 +02:00
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2010-01-28 22:42:03 +01:00
|
|
|
- (WOCookie *) _cookieWithUsername: (NSString *) username
|
|
|
|
andPassword: (NSString *) password
|
|
|
|
forAuthenticator: (SOGoWebAuthenticator *) auth
|
|
|
|
{
|
|
|
|
WOCookie *authCookie;
|
|
|
|
NSString *cookieValue, *cookieString, *appName;
|
|
|
|
|
|
|
|
cookieString = [NSString stringWithFormat: @"%@:%@",
|
|
|
|
username, password];
|
|
|
|
cookieValue = [NSString stringWithFormat: @"basic %@",
|
|
|
|
[cookieString stringByEncodingBase64]];
|
|
|
|
authCookie = [WOCookie cookieWithName: [auth cookieNameInContext: context]
|
|
|
|
value: cookieValue];
|
|
|
|
appName = [[context request] applicationName];
|
|
|
|
[authCookie setPath: [NSString stringWithFormat: @"/%@/", appName]];
|
|
|
|
/* enable this when we have code to determine whether request is HTTPS:
|
|
|
|
[authCookie setIsSecure: YES]; */
|
|
|
|
|
|
|
|
return authCookie;
|
|
|
|
}
|
|
|
|
|
2010-02-18 22:39:25 +01:00
|
|
|
- (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;
|
|
|
|
}
|
|
|
|
|
2007-09-07 00:21:16 +02:00
|
|
|
/* actions */
|
2010-03-08 21:52:37 +01:00
|
|
|
- (WOResponse *) _responseWithLDAPPolicyError: (int) error
|
|
|
|
{
|
|
|
|
NSDictionary *jsonError;
|
|
|
|
|
|
|
|
jsonError
|
|
|
|
= [NSDictionary dictionaryWithObject: [NSNumber numberWithInt: error]
|
|
|
|
forKey: @"LDAPPasswordPolicyError"];
|
2010-03-09 21:33:00 +01:00
|
|
|
return [self responseWithStatus: 403
|
|
|
|
andJSONRepresentation: jsonError];
|
2010-03-08 21:52:37 +01:00
|
|
|
}
|
|
|
|
|
2007-09-07 00:21:16 +02:00
|
|
|
- (id <WOActionResults>) connectAction
|
2007-09-04 17:00:44 +02:00
|
|
|
{
|
2007-09-07 00:21:16 +02:00
|
|
|
WOResponse *response;
|
2007-11-21 17:42:58 +01:00
|
|
|
WORequest *request;
|
2007-09-07 00:21:16 +02:00
|
|
|
WOCookie *authCookie;
|
2007-09-04 17:41:59 +02:00
|
|
|
SOGoWebAuthenticator *auth;
|
2009-11-29 05:19:32 +01:00
|
|
|
SOGoUserDefaults *ud;
|
2010-01-28 22:42:03 +01:00
|
|
|
NSString *username, *password, *language;
|
2009-11-29 05:19:32 +01:00
|
|
|
NSArray *supportedLanguages;
|
2010-03-08 16:18:05 +01:00
|
|
|
|
|
|
|
SOGoPasswordPolicyError err;
|
|
|
|
int expire, grace;
|
|
|
|
BOOL b;
|
|
|
|
|
|
|
|
err = PolicyNoError;
|
2010-03-15 00:07:42 +01:00
|
|
|
expire = grace = -1;
|
2010-03-08 16:18:05 +01:00
|
|
|
|
2007-09-07 00:21:16 +02:00
|
|
|
auth = [[WOApplication application]
|
2010-03-08 16:18:05 +01:00
|
|
|
authenticatorInContext: context];
|
2007-11-21 17:42:58 +01:00
|
|
|
request = [context request];
|
2010-01-28 22:42:03 +01:00
|
|
|
username = [request formValueForKey: @"userName"];
|
2008-08-26 19:42:03 +02:00
|
|
|
password = [request formValueForKey: @"password"];
|
2008-11-05 18:26:02 +01:00
|
|
|
language = [request formValueForKey: @"language"];
|
2010-03-08 16:18:05 +01:00
|
|
|
|
2010-03-08 21:52:37 +01:00
|
|
|
if ((b = [auth checkLogin: username password: password
|
|
|
|
perr: &err expire: &expire grace: &grace])
|
2010-03-15 00:07:42 +01:00
|
|
|
&& (err == PolicyNoError)
|
|
|
|
// no password policy
|
|
|
|
&& ((expire < 0 && grace < 0) // no password policy or everything is alright
|
|
|
|
|| (expire < 0 && grace > 0) // password expired, grace still permits login
|
2010-03-29 02:49:29 +02:00
|
|
|
|| (expire >= 0 && grace == -1))) // password about to expire OR ppolicy activated and passwd never changed
|
2008-08-26 19:42:03 +02:00
|
|
|
{
|
2010-03-15 00:07:42 +01:00
|
|
|
NSDictionary *json;
|
|
|
|
|
|
|
|
[self logWithFormat: @"successful login for user '%@' - expire = %d grace = %d", username, expire, grace];
|
|
|
|
|
|
|
|
|
|
|
|
json = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt: expire], @"expire",
|
|
|
|
[NSNumber numberWithInt: grace], @"grace", nil];
|
|
|
|
|
|
|
|
response = [self responseWithStatus: 200
|
|
|
|
andJSONRepresentation: json];
|
|
|
|
|
2010-01-28 22:42:03 +01:00
|
|
|
authCookie = [self _cookieWithUsername: username andPassword: password
|
|
|
|
forAuthenticator: auth];
|
2008-08-26 19:42:03 +02:00
|
|
|
[response addCookie: authCookie];
|
2008-11-05 18:26:02 +01:00
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
supportedLanguages = [[SOGoSystemDefaults sharedSystemDefaults]
|
|
|
|
supportedLanguages];
|
2008-12-18 23:11:13 +01:00
|
|
|
if (language && [supportedLanguages containsObject: language])
|
2008-11-05 18:26:02 +01:00
|
|
|
{
|
2010-01-28 22:42:03 +01:00
|
|
|
ud = [[SOGoUser userWithLogin: username] userDefaults];
|
2009-11-29 05:19:32 +01:00
|
|
|
[ud setLanguage: language];
|
|
|
|
[ud synchronize];
|
2008-11-05 18:26:02 +01:00
|
|
|
}
|
2008-08-26 19:42:03 +02:00
|
|
|
}
|
|
|
|
else
|
2008-09-11 23:55:21 +02:00
|
|
|
{
|
2010-03-15 00:07:42 +01:00
|
|
|
[self logWithFormat: @"Login for user '%@' might not have worked - password policy: %d grace: %d expire: %d bound: %d", username, err, grace, expire, b];
|
2010-03-08 21:52:37 +01:00
|
|
|
|
|
|
|
response = [self _responseWithLDAPPolicyError: err];
|
2008-09-11 23:55:21 +02:00
|
|
|
}
|
2007-09-07 00:21:16 +02:00
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2010-01-28 22:42:03 +01:00
|
|
|
- (NSDictionary *) _casRedirectKeys
|
2007-09-12 15:01:17 +02:00
|
|
|
{
|
2010-01-28 22:42:03 +01:00
|
|
|
NSDictionary *redirectKeys;
|
|
|
|
NSURL *soURL;
|
|
|
|
|
|
|
|
soURL = [[WOApplication application] soURL];
|
|
|
|
|
|
|
|
redirectKeys = [NSDictionary dictionaryWithObject: [soURL absoluteString]
|
|
|
|
forKey: @"service"];
|
|
|
|
|
|
|
|
return redirectKeys;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id <WOActionResults>) casProxyAction
|
|
|
|
{
|
|
|
|
SOGoCache *cache;
|
|
|
|
WORequest *request;
|
|
|
|
NSString *pgtId, *pgtIou;
|
|
|
|
|
|
|
|
request = [context request];
|
|
|
|
pgtId = [request formValueForKey: @"pgtId"];
|
|
|
|
pgtIou = [request formValueForKey: @"pgtIou"];
|
|
|
|
if ([pgtId length] && [pgtIou length])
|
|
|
|
{
|
|
|
|
cache = [SOGoCache sharedCache];
|
|
|
|
[cache setCASPGTId: pgtId forPGTIOU: pgtIou];
|
|
|
|
}
|
|
|
|
|
|
|
|
return [self responseWithStatus: 200];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id <WOActionResults>) _casDefaultAction
|
|
|
|
{
|
|
|
|
WOResponse *response;
|
|
|
|
NSString *login, *newLocation, *oldLocation, *ticket;
|
|
|
|
SOGoCASSession *casSession;
|
|
|
|
SOGoWebAuthenticator *auth;
|
2010-02-18 22:39:25 +01:00
|
|
|
WOCookie *casCookie, *casLocationCookie;
|
|
|
|
WORequest *rq;
|
2010-01-28 22:42:03 +01:00
|
|
|
|
|
|
|
casCookie = nil;
|
2010-02-18 22:39:25 +01:00
|
|
|
casLocationCookie = nil;
|
|
|
|
|
|
|
|
newLocation = nil;
|
2007-09-12 15:01:17 +02:00
|
|
|
|
|
|
|
login = [[context activeUser] login];
|
2010-01-28 22:42:03 +01:00
|
|
|
if ([login isEqualToString: @"anonymous"])
|
|
|
|
login = nil;
|
|
|
|
if (!login)
|
|
|
|
{
|
2010-02-18 22:39:25 +01:00
|
|
|
rq = [context request];
|
|
|
|
ticket = [rq formValueForKey: @"ticket"];
|
2010-01-28 22:42:03 +01:00
|
|
|
if ([ticket length])
|
|
|
|
{
|
|
|
|
casSession = [SOGoCASSession CASSessionWithTicket: ticket];
|
|
|
|
login = [casSession login];
|
|
|
|
if ([login length])
|
|
|
|
{
|
|
|
|
auth = [[WOApplication application]
|
|
|
|
authenticatorInContext: context];
|
|
|
|
casCookie = [self _cookieWithUsername: login
|
|
|
|
andPassword: [casSession identifier]
|
|
|
|
forAuthenticator: auth];
|
|
|
|
[casSession updateCache];
|
2010-02-18 22:39:25 +01:00
|
|
|
newLocation = [rq cookieValueForKey: @"cas-location"];
|
|
|
|
/* login callback, we expire the "cas-location" cookie, created
|
|
|
|
below */
|
|
|
|
casLocationCookie = [self _casLocationCookie: YES];
|
2010-01-28 22:42:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-02-18 22:39:25 +01:00
|
|
|
else
|
|
|
|
ticket = nil;
|
2010-01-28 22:42:03 +01:00
|
|
|
|
|
|
|
if (login)
|
|
|
|
{
|
2010-02-18 22:39:25 +01:00
|
|
|
/* 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]];
|
|
|
|
}
|
2010-01-28 22:42:03 +01:00
|
|
|
}
|
2007-09-12 15:01:17 +02:00
|
|
|
else
|
2010-02-18 22:39:25 +01:00
|
|
|
{
|
|
|
|
newLocation
|
|
|
|
= [SOGoCASSession CASURLWithAction: @"login"
|
|
|
|
andParameters: [self _casRedirectKeys]];
|
|
|
|
casLocationCookie = [self _casLocationCookie: NO];
|
|
|
|
}
|
2010-01-28 22:42:03 +01:00
|
|
|
response = [self redirectToLocation: newLocation];
|
|
|
|
if (casCookie)
|
|
|
|
[response addCookie: casCookie];
|
2010-02-18 22:39:25 +01:00
|
|
|
if (casLocationCookie)
|
|
|
|
[response addCookie: casLocationCookie];
|
2010-01-28 22:42:03 +01:00
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id <WOActionResults>) _standardDefaultAction
|
|
|
|
{
|
|
|
|
NSObject <WOActionResults> *response;
|
|
|
|
NSString *login, *oldLocation;
|
|
|
|
|
|
|
|
login = [[context activeUser] login];
|
|
|
|
if ([login isEqualToString: @"anonymous"])
|
|
|
|
login = nil;
|
|
|
|
|
|
|
|
if (login)
|
2007-09-12 15:01:17 +02:00
|
|
|
{
|
|
|
|
oldLocation = [[self clientObject] baseURLInContext: context];
|
|
|
|
response
|
2010-01-28 22:42:03 +01:00
|
|
|
= [self redirectToLocation: [NSString stringWithFormat: @"%@%@",
|
2009-09-11 16:38:43 +02:00
|
|
|
oldLocation,
|
|
|
|
[login stringByEscapingURL]]];
|
2007-09-12 15:01:17 +02:00
|
|
|
}
|
2010-01-28 22:42:03 +01:00
|
|
|
else
|
2010-02-03 15:56:38 +01:00
|
|
|
{
|
|
|
|
oldLocation = [[context request] uri];
|
2010-02-03 17:09:18 +01:00
|
|
|
if ([context clientObject]
|
|
|
|
&& ![oldLocation hasSuffix: @"/"]
|
2010-02-03 15:56:38 +01:00
|
|
|
&& ![oldLocation hasSuffix: @"/view"])
|
|
|
|
response = [self redirectToLocation:
|
|
|
|
[NSString stringWithFormat: @"%@/", oldLocation]];
|
|
|
|
else
|
|
|
|
response = self;
|
|
|
|
}
|
2007-09-12 15:01:17 +02:00
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2010-01-28 22:42:03 +01:00
|
|
|
- (id <WOActionResults>) defaultAction
|
|
|
|
{
|
|
|
|
SOGoSystemDefaults *sd;
|
|
|
|
|
|
|
|
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
|
|
|
|
|
|
|
return ([[sd authenticationType] isEqualToString: @"cas"]
|
|
|
|
? [self _casDefaultAction]
|
|
|
|
: [self _standardDefaultAction]);
|
|
|
|
}
|
|
|
|
|
2007-09-05 19:56:39 +02:00
|
|
|
- (BOOL) isPublicInContext: (WOContext *) localContext
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2007-12-13 20:26:47 +01:00
|
|
|
- (id <WOActionResults>) crashAction
|
|
|
|
{
|
|
|
|
[self segfault];
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id <WOActionResults>) exceptionAction
|
|
|
|
{
|
|
|
|
return (id <WOActionResults>)
|
|
|
|
[NSException exceptionWithName: @"ExceptionAction"
|
|
|
|
reason: @"This exception is brought to you by SOGo"
|
|
|
|
userInfo: nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id <WOActionResults>) raisedExceptionAction
|
|
|
|
{
|
|
|
|
[NSException raise: @"ExceptionAction"
|
|
|
|
format: @"This exception is brought to you by SOGo"];
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2008-05-22 17:56:18 +02:00
|
|
|
- (NSString *) loginSuffix
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [[SOGoSystemDefaults sharedSystemDefaults] loginSuffix];
|
2008-05-22 17:56:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) hasLoginSuffix
|
|
|
|
{
|
|
|
|
return ([[self loginSuffix] length]);
|
|
|
|
}
|
|
|
|
|
2008-11-05 18:26:02 +01:00
|
|
|
- (void) setItem: (id) _item
|
|
|
|
{
|
|
|
|
ASSIGN (item, _item);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) item
|
|
|
|
{
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) languages
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [[SOGoSystemDefaults sharedSystemDefaults] supportedLanguages];
|
2008-11-05 18:26:02 +01:00
|
|
|
}
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
// - (NSString *) language
|
|
|
|
// {
|
|
|
|
// return [SOGoUser language];
|
|
|
|
// }
|
2008-11-05 18:26:02 +01:00
|
|
|
|
|
|
|
- (NSString *) languageText
|
|
|
|
{
|
|
|
|
NSString *text;
|
|
|
|
|
|
|
|
text = [self labelForKey: item];
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2009-03-19 03:42:35 +01:00
|
|
|
- (NSString *) version
|
|
|
|
{
|
|
|
|
NSString *aString;
|
|
|
|
|
|
|
|
aString = [NSString stringWithFormat: @"%d.%d.%d",
|
|
|
|
SOGO_MAJOR_VERSION,
|
|
|
|
SOGO_MINOR_VERSION,
|
|
|
|
SOGO_SUBMINOR_VERSION];
|
|
|
|
|
|
|
|
return aString;
|
|
|
|
}
|
|
|
|
|
2010-03-08 16:18:05 +01:00
|
|
|
- (WOResponse *) changePasswordAction
|
|
|
|
{
|
|
|
|
NSString *username, *password, *newPassword;
|
|
|
|
SOGoUserManager *um;
|
|
|
|
SOGoPasswordPolicyError error;
|
|
|
|
WOResponse *response;
|
|
|
|
WORequest *request;
|
2010-03-08 21:52:37 +01:00
|
|
|
NSDictionary *message;
|
|
|
|
SOGoWebAuthenticator *auth;
|
|
|
|
WOCookie *authCookie;
|
2010-03-08 16:18:05 +01:00
|
|
|
|
|
|
|
request = [context request];
|
|
|
|
message = [NSMutableDictionary dictionaryWithJSONString: [request contentAsString]];
|
|
|
|
username = [message objectForKey: @"userName"];
|
|
|
|
password = [message objectForKey: @"password"];
|
|
|
|
newPassword = [message objectForKey: @"newPassword"];
|
|
|
|
|
|
|
|
um = [SOGoUserManager sharedUserManager];
|
|
|
|
|
|
|
|
// This will also update the cached password in memcached.
|
|
|
|
if ([um changePasswordForLogin: username
|
|
|
|
oldPassword: password
|
|
|
|
newPassword: newPassword
|
|
|
|
perr: &error])
|
|
|
|
{
|
2010-03-08 21:52:37 +01:00
|
|
|
response = [self responseWith204];
|
|
|
|
auth = [[WOApplication application]
|
|
|
|
authenticatorInContext: context];
|
|
|
|
authCookie = [self _cookieWithUsername: username
|
|
|
|
andPassword: newPassword
|
|
|
|
forAuthenticator: auth];
|
|
|
|
[response addCookie: authCookie];
|
2010-03-08 16:18:05 +01:00
|
|
|
}
|
2010-03-08 21:52:37 +01:00
|
|
|
else
|
|
|
|
response = [self _responseWithLDAPPolicyError: error];
|
2010-03-08 16:18:05 +01:00
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
@end /* SOGoRootPage */
|