Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Kitodo/src/main/java/org/kitodo/production/forms/LoginForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
import jakarta.faces.context.FacesContext;
import jakarta.inject.Named;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.kitodo.data.database.beans.User;
import org.kitodo.data.database.exceptions.DAOException;
import org.kitodo.production.controller.SessionClientController;
import org.kitodo.production.helper.Helper;
import org.kitodo.production.security.CustomLoginSuccessHandler;
import org.kitodo.production.services.ServiceManager;
import org.kitodo.production.services.security.SecurityAccessService;
Expand All @@ -31,6 +34,7 @@
@Named("LoginForm")
@SessionScoped
public class LoginForm implements Serializable {
private static final Logger logger = LogManager.getLogger(LoginForm.class);
private User loggedUser;
private boolean firstVisit = true;
private static final String INDEXING_PAGE = "system?tabIndex=";
Expand Down Expand Up @@ -121,6 +125,16 @@ public void performPostLoginChecks() throws DAOException, IOException {
}
}

/**
* Write the original error message to the log files and return a save generic error message to the user.
* @param errorMessage the original error message
* @return the generic error message presented to the user
*/
public String getGenericErrorMessage(String errorMessage) {
logger.error(errorMessage);
return Helper.getTranslation("loginBadCredentials");
}

private void redirect(ExternalContext context) throws IOException {
String originalRequest = CustomLoginSuccessHandler.getOriginalRequest(context.getSessionMap()
.get(CustomLoginSuccessHandler.getSavedRequestString()));
Expand Down
1 change: 1 addition & 0 deletions Kitodo/src/main/resources/messages/errors_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ errorLoadingMany=Fehler beim Laden von ''{0}''
errorLoadingOne=Fehler beim Laden von ''{0}'' mit ID {1}
errorLoadingMetadataFile=Fehler beim Laden der Metadatendatei
ldapGroupInUse=Die LDAP Gruppe ist noch mit Benutzern verknüpft und kann nicht gelöscht werden.
loginBadCredentials=Ungültige Anmeldeinformationen.
loginInUse=Login ist bereits vergeben
loginNotValid=Login ''{0}'' enthält ungültige Zeichen oder ist auf der Sperrliste.

Expand Down
1 change: 1 addition & 0 deletions Kitodo/src/main/resources/messages/errors_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ errorLoadingMetadataFile=Error loading metadata file
ldapGroupInUse=The LDAP group is still associated with users and could not be deleted.
loginInUse=Login already in use
loginNotValid=Login ''{0}'' uses not valid characters or is on the denylist.
loginBadCredentials=Bad credentials.

# M
errorMassDownloadProjectCreation=The project folder {0} could not be created.
Expand Down
1 change: 1 addition & 0 deletions Kitodo/src/main/resources/messages/errors_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ errorLoadingMany=Error al cargar ''{0}''
errorLoadingOne=Error al cargar ''{0}'' con ID {1}
errorLoadingMetadataFile=Error al cargar el archivo de los metadatos
ldapGroupInUse=El grupo LDAP sigue vinculado a los usuarios y no puede ser eliminado.
loginBadCredentials=El inicio de sesión o la contraseña son incorrectos.
loginInUse=El inicio de sesión ya está asignado
loginNotValid=El inicio de sesión ''{0}'' contiene caracteres no válidos o está en la lista de denegados.

Expand Down
3 changes: 2 additions & 1 deletion Kitodo/src/main/webapp/pages/login.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
<h3>#{msgs.pleaseSignIn}</h3>
<form action="${request.contextPath}/login" method="post">
<span style="color: red; ">
<h:outputText value="${SPRING_SECURITY_LAST_EXCEPTION.localizedMessage}"/>
<h:outputText rendered="${not empty SPRING_SECURITY_LAST_EXCEPTION.localizedMessage}"
value="#{LoginForm.getGenericErrorMessage(SPRING_SECURITY_LAST_EXCEPTION.localizedMessage)}"/>
</span>
<div>
<label for="username">#{msgs.username}</label>
Expand Down