if (source == chPwdForm) {
if (event == Form.EVNT_VALIDATION_OK) { // form validation was ok
// Form data is ok
// verify old password
String oldPwd = chPwdForm.getOldPasswordValue();
Identity provenIdent = null;
if(ManagerFactory.getManager().findAuthentication(ureq.getIdentity(), LDAPAuthenticationController.PROVIDER_LDAP) != null) {
LDAPError ldapError = new LDAPError();
//fallback to OLAT if enabled happen automatically in LDAPAuthenticationController
provenIdent = LDAPAuthenticationController.authenticate(ureq.getIdentity().getName(), oldPwd, ldapError);
}
else if(ManagerFactory.getManager().findAuthentication(ureq.getIdentity(), OLATAuthenticationController.PROVIDER_OLAT) != null) {
provenIdent = OLATAuthenticationController.authenticate(ureq.getIdentity().getName(), oldPwd);
}
if (provenIdent == null) {
getWindowControl().setError(translate("error.password.noauth"));
}
else {
String newPwd = chPwdForm.getNewPasswordValue();
if(OLATAuthManager.changePassword(ureq.getIdentity(), provenIdent, newPwd)) {
//TODO: verify that we are NOT in a transaction (changepwd should be commited immediately)
log.audit("Changed password for identity."+provenIdent.getName());
getWindowControl().setInfo(translate("password.successful"));
} else {
getWindowControl().setInfo(translate("password.failed"));
}
}