mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-06 04:20:33 +00:00
See ChangeLog.
Monotone-Parent: 9b2ef440fdc7d9495d4f165d7fafc6bd0b2d6068 Monotone-Revision: 9622fc005299a8ed3c143c177667be6f33df9523 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2011-10-25T20:58:18
This commit is contained in:
@@ -58,6 +58,22 @@
|
||||
|
||||
@implementation SOGoRootPage
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
cookieLogin = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[cookieLogin release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
/* accessors */
|
||||
|
||||
- (NSString *) connectURL
|
||||
@@ -65,6 +81,25 @@
|
||||
return [NSString stringWithFormat: @"%@/connect", [self applicationPath]];
|
||||
}
|
||||
|
||||
- (NSString *) cookieUsername
|
||||
{
|
||||
NSString *value;
|
||||
|
||||
if (cookieLogin == nil)
|
||||
{
|
||||
value = [[context request] cookieValueForKey: @"SOGoLogin"];
|
||||
cookieLogin = [value isNotNull]? [value stringByDecodingBase64] : @"";
|
||||
[cookieLogin retain];
|
||||
}
|
||||
|
||||
return cookieLogin;
|
||||
}
|
||||
|
||||
- (BOOL) rememberLogin
|
||||
{
|
||||
return ([[self cookieUsername] length]);
|
||||
}
|
||||
|
||||
- (WOCookie *) _cookieWithUsername: (NSString *) username
|
||||
andPassword: (NSString *) password
|
||||
forAuthenticator: (SOGoWebAuthenticator *) auth
|
||||
@@ -105,6 +140,32 @@
|
||||
return authCookie;
|
||||
}
|
||||
|
||||
- (WOCookie *) _cookieWithUsername: (NSString *) username
|
||||
{
|
||||
WOCookie *loginCookie;
|
||||
NSString *appName;
|
||||
NSCalendarDate *date;
|
||||
|
||||
appName = [[context request] applicationName];
|
||||
if (username)
|
||||
{
|
||||
loginCookie = [WOCookie cookieWithName: @"SOGoLogin"
|
||||
value: [username stringByEncodingBase64]];
|
||||
}
|
||||
else
|
||||
{
|
||||
loginCookie = [WOCookie cookieWithName: @"SOGoLogin"
|
||||
value: nil];
|
||||
date = [NSCalendarDate calendarDate];
|
||||
[date setTimeZone: [NSTimeZone timeZoneWithAbbreviation: @"GMT"]];
|
||||
[loginCookie setExpires: [date yesterday]];
|
||||
}
|
||||
|
||||
[loginCookie setPath: [NSString stringWithFormat: @"/%@/", appName]];
|
||||
|
||||
return loginCookie;
|
||||
}
|
||||
|
||||
- (WOCookie *) _casLocationCookie: (BOOL) cookieReset
|
||||
{
|
||||
WOCookie *locationCookie;
|
||||
@@ -155,7 +216,7 @@
|
||||
|
||||
SOGoPasswordPolicyError err;
|
||||
int expire, grace;
|
||||
BOOL b;
|
||||
BOOL rememberLogin, b;
|
||||
|
||||
err = PolicyNoError;
|
||||
expire = grace = -1;
|
||||
@@ -166,6 +227,7 @@
|
||||
username = [request formValueForKey: @"userName"];
|
||||
password = [request formValueForKey: @"password"];
|
||||
language = [request formValueForKey: @"language"];
|
||||
rememberLogin = [[request formValueForKey: @"rememberLogin"] boolValue];
|
||||
domain = [request formValueForKey: @"domain"];
|
||||
|
||||
if ((b = [auth checkLogin: username password: password domain: &domain
|
||||
@@ -220,6 +282,11 @@
|
||||
response = [self _responseWithLDAPPolicyError: err];
|
||||
}
|
||||
|
||||
if (rememberLogin)
|
||||
[response addCookie: [self _cookieWithUsername: username]];
|
||||
else
|
||||
[response addCookie: [self _cookieWithUsername: nil]];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user