diff --git a/SoObjects/SOGo/SOGoUserManager.h b/SoObjects/SOGo/SOGoUserManager.h index 23ef643df..6564e10b2 100644 --- a/SoObjects/SOGo/SOGoUserManager.h +++ b/SoObjects/SOGo/SOGoUserManager.h @@ -82,11 +82,19 @@ - (NSString *) getLoginForDN: (NSString *) theDN; - (BOOL) checkLogin: (NSString *) _login - password: (NSString *) _pwd + password: (NSString *) _pwd domain: (NSString **) _domain - perr: (SOGoPasswordPolicyError *) _perr - expire: (int *) _expire - grace: (int *) _grace; + perr: (SOGoPasswordPolicyError *) _perr + expire: (int *) _expire + grace: (int *) _grace; + +- (BOOL) checkLogin: (NSString *) _login + password: (NSString *) _pwd + domain: (NSString **) _domain + perr: (SOGoPasswordPolicyError *) _perr + expire: (int *) _expire + grace: (int *) _grace + useCache: (BOOL) _useCache; - (BOOL) changePasswordForLogin: (NSString *) login inDomain: (NSString *) domain diff --git a/SoObjects/SOGo/SOGoUserManager.m b/SoObjects/SOGo/SOGoUserManager.m index 28fec2a21..d6a0f9a5b 100644 --- a/SoObjects/SOGo/SOGoUserManager.m +++ b/SoObjects/SOGo/SOGoUserManager.m @@ -448,11 +448,28 @@ static Class NSNullK; } - (BOOL) checkLogin: (NSString *) _login - password: (NSString *) _pwd + password: (NSString *) _pwd domain: (NSString **) _domain - perr: (SOGoPasswordPolicyError *) _perr - expire: (int *) _expire - grace: (int *) _grace + perr: (SOGoPasswordPolicyError *) _perr + expire: (int *) _expire + grace: (int *) _grace +{ + return [self checkLogin: _login + password: _pwd + domain: _domain + perr: _perr + expire: _expire + grace: _grace + useCache: YES]; +} + +- (BOOL) checkLogin: (NSString *) _login + password: (NSString *) _pwd + domain: (NSString **) _domain + perr: (SOGoPasswordPolicyError *) _perr + expire: (int *) _expire + grace: (int *) _grace + useCache: (BOOL) useCache { NSString *dictPassword, *username, *jsonUser; NSMutableDictionary *currentUser; @@ -468,7 +485,7 @@ static Class NSNullK; jsonUser = [[SOGoCache sharedCache] userAttributesForLogin: username]; currentUser = [jsonUser objectFromJSONString]; dictPassword = [currentUser objectForKey: @"password"]; - if (currentUser && dictPassword) + if (useCache && currentUser && dictPassword) { checkOK = ([dictPassword isEqualToString: [_pwd asSHA1String]]); //NSLog(@"Password cache hit for user %@", _login); @@ -482,9 +499,9 @@ static Class NSNullK; { checkOK = YES; if (!currentUser) - { - currentUser = [NSMutableDictionary dictionary]; - } + { + currentUser = [NSMutableDictionary dictionary]; + } // It's important to cache the password here as we might have cached the // user's entry in -contactInfosForUserWithUIDorEmail: and if we don't diff --git a/SoObjects/SOGo/SOGoWebAuthenticator.h b/SoObjects/SOGo/SOGoWebAuthenticator.h index 5a3533c70..a2d9eeb5b 100644 --- a/SoObjects/SOGo/SOGoWebAuthenticator.h +++ b/SoObjects/SOGo/SOGoWebAuthenticator.h @@ -42,11 +42,19 @@ + (id) sharedSOGoWebAuthenticator; - (BOOL) checkLogin: (NSString *) _login - password: (NSString *) _pwd + password: (NSString *) _pwd domain: (NSString **) _domain - perr: (SOGoPasswordPolicyError *) _perr - expire: (int *) _expire - grace: (int *) _grace; + perr: (SOGoPasswordPolicyError *) _perr + expire: (int *) _expire + grace: (int *) _grace; + +- (BOOL) checkLogin: (NSString *) _login + password: (NSString *) _pwd + domain: (NSString **) _domain + perr: (SOGoPasswordPolicyError *) _perr + expire: (int *) _expire + grace: (int *) _grace + useCache: (BOOL) useCache; - (WOCookie *) cookieWithUsername: (NSString *) username andPassword: (NSString *) password diff --git a/SoObjects/SOGo/SOGoWebAuthenticator.m b/SoObjects/SOGo/SOGoWebAuthenticator.m index a4e722811..bb35f2789 100644 --- a/SoObjects/SOGo/SOGoWebAuthenticator.m +++ b/SoObjects/SOGo/SOGoWebAuthenticator.m @@ -110,11 +110,28 @@ } - (BOOL) checkLogin: (NSString *) _login - password: (NSString *) _pwd + password: (NSString *) _pwd domain: (NSString **) _domain - perr: (SOGoPasswordPolicyError *) _perr - expire: (int *) _expire - grace: (int *) _grace + perr: (SOGoPasswordPolicyError *) _perr + expire: (int *) _expire + grace: (int *) _grace +{ + return [self checkLogin: _login + password: _pwd + domain: _domain + perr: _perr + expire: _expire + grace: _grace + useCache: YES]; +} + +- (BOOL) checkLogin: (NSString *) _login + password: (NSString *) _pwd + domain: (NSString **) _domain + perr: (SOGoPasswordPolicyError *) _perr + expire: (int *) _expire + grace: (int *) _grace + useCache: (BOOL) _useCache { SOGoCASSession *session; SOGoSystemDefaults *sd; @@ -150,7 +167,8 @@ domain: _domain perr: _perr expire: _expire - grace: _grace]; + grace: _grace + useCache: _useCache]; //[self logWithFormat: @"Checked login with ppolicy enabled: %d %d %d", *_perr, *_expire, *_grace]; diff --git a/UI/MainUI/SOGoRootPage.m b/UI/MainUI/SOGoRootPage.m index 50d1fba43..f28ea533f 100644 --- a/UI/MainUI/SOGoRootPage.m +++ b/UI/MainUI/SOGoRootPage.m @@ -202,7 +202,7 @@ domain = [request formValueForKey: @"domain"]; if ((b = [auth checkLogin: username password: password domain: &domain - perr: &err expire: &expire grace: &grace]) + perr: &err expire: &expire grace: &grace useCache: NO]) && (err == PolicyNoError) // no password policy && ((expire < 0 && grace < 0) // no password policy or everything is alright