Skip to content
Snippets Groups Projects
Commit 31f0f390 authored by srosse's avatar srosse
Browse files

OO-4514: prevent second query for user data

parent 0ca11e0e
No related branches found
No related tags found
No related merge requests found
......@@ -1051,6 +1051,7 @@ public class BaseSecurityManager implements BaseSecurity, UserDataDeletable {
StringBuilder sb = new StringBuilder();
sb.append("select auth from ").append(AuthenticationImpl.class.getName()).append(" as auth")
.append(" inner join fetch auth.identity ident")
.append(" inner join fetch ident.user identUser")
.append(" where auth.provider=:provider and auth.authusername=:authusername");
List<Authentication> results = dbInstance.getCurrentEntityManager()
......@@ -1070,6 +1071,7 @@ public class BaseSecurityManager implements BaseSecurity, UserDataDeletable {
StringBuilder sb = new StringBuilder();
sb.append("select auth from ").append(AuthenticationImpl.class.getName()).append(" as auth")
.append(" inner join fetch auth.identity ident")
.append(" inner join fetch ident.user identUser")
.append(" where auth.provider in (:providers) and auth.authusername=:authusername");
return dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), Authentication.class)
......
......@@ -125,7 +125,7 @@ public class OLATAuthManager implements AuthenticationSPI {
if(identities.size() == 1) {
ident = identities.get(0);
} else if(identities.size() > 1) {
log.error("more than one identity found with email::" + login);
log.error("more than one identity found with email::{}", login);
}
if (ident == null) {
......@@ -245,7 +245,7 @@ public class OLATAuthManager implements AuthenticationSPI {
if(ldapLoginModule.isPropagatePasswordChangedOnLdapServer()) {
LDAPError ldapError = new LDAPError();
ldapLoginManager.changePassword(identity, newPwd, ldapError);
log.info(Tracing.M_AUDIT, doer.getKey() + " change the password on the LDAP server for identity: " + identity.getKey());
log.info(Tracing.M_AUDIT, "{} change the password on the LDAP server for identity: {}", doer.getKey(), identity.getKey());
allOk = ldapError.isEmpty();
if(allOk && ldapLoginModule.isCacheLDAPPwdAsOLATPwdOnLogin()) {
......@@ -304,10 +304,10 @@ public class OLATAuthManager implements AuthenticationSPI {
Authentication auth = securityManager.findAuthentication(identity, "OLAT");
if (auth == null) { // create new authentication for provider OLAT
securityManager.createAndPersistAuthentication(identity, "OLAT", identity.getName(), newPwd, loginModule.getDefaultHashAlgorithm());
log.info(Tracing.M_AUDIT, doer.getKey() + " created new authenticatin for identity: " + identity.getKey());
log.info(Tracing.M_AUDIT, "{} created new authenticatin for identity: {}", doer.getKey(), identity.getKey());
} else {
securityManager.updateCredentials(auth, newPwd, loginModule.getDefaultHashAlgorithm());
log.info(Tracing.M_AUDIT, doer.getKey() + " set new password for identity: " + identity.getKey());
log.info(Tracing.M_AUDIT, "{} set new password for identity: {}", doer.getKey(), identity.getKey());
}
if(StringHelper.containsNonWhitespace(username) && webDAVAuthManager != null) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment