diff --git a/ChangeLog b/ChangeLog index b07b4595d..5d5ae402c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-10-25 Francis Lachapelle + + * UI/MainUI/SOGoRootPage.m (-cookieUsername) + (-cookieWithUsername:): getter/setter for the new SOGoLogin + cookie. This is used for the new "Remember username" checkbox that + appears on the login page. + 2011-10-24 Wolfgang Sourdeau * OpenChange/MAPIStoreAttachment.m diff --git a/UI/MainUI/English.lproj/Localizable.strings b/UI/MainUI/English.lproj/Localizable.strings index 2cc33df23..d99d0fb23 100644 --- a/UI/MainUI/English.lproj/Localizable.strings +++ b/UI/MainUI/English.lproj/Localizable.strings @@ -5,6 +5,7 @@ "Username:" = "Username:"; "Password:" = "Password:"; "Domain:" = "Domain:"; +"Remember username" = "Remember username"; "Connect" = "Connect"; diff --git a/UI/MainUI/French.lproj/Localizable.strings b/UI/MainUI/French.lproj/Localizable.strings index 43fd8c2cc..e61648eb3 100644 --- a/UI/MainUI/French.lproj/Localizable.strings +++ b/UI/MainUI/French.lproj/Localizable.strings @@ -5,6 +5,7 @@ "Username:" = "Nom d'utilisateur :"; "Password:" = "Mot de passe :"; "Domain:" = "Domaine :"; +"Remember username" = "Se souvenir de moi"; "Connect" = "Connexion"; diff --git a/UI/MainUI/SOGoRootPage.h b/UI/MainUI/SOGoRootPage.h index 6bbad00bf..acee8c049 100644 --- a/UI/MainUI/SOGoRootPage.h +++ b/UI/MainUI/SOGoRootPage.h @@ -28,6 +28,7 @@ @interface SOGoRootPage : UIxComponent { id item; + NSString *cookieLogin; } @end diff --git a/UI/MainUI/SOGoRootPage.m b/UI/MainUI/SOGoRootPage.m index a960572ff..21d494186 100644 --- a/UI/MainUI/SOGoRootPage.m +++ b/UI/MainUI/SOGoRootPage.m @@ -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; } diff --git a/UI/Templates/MainUI/SOGoRootPage.wox b/UI/Templates/MainUI/SOGoRootPage.wox index 70060a4ac..3f40b92de 100644 --- a/UI/Templates/MainUI/SOGoRootPage.wox +++ b/UI/Templates/MainUI/SOGoRootPage.wox @@ -38,7 +38,7 @@ + type="text" var:value="cookieUsername" /> @@ -61,6 +61,7 @@ string="item" /> +