Skip to content
Snippets Groups Projects
Commit ddd65c3d authored by Robert Goldmann's avatar Robert Goldmann
Browse files

Fixed #644 - trim text inputs before save

parent 63bd429b
No related branches found
No related tags found
No related merge requests found
package de.deadlocker8.budgetmaster.advices;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.InitBinder;
@ControllerAdvice
public class GlobalControllerAdvice
{
@InitBinder
public void initBinder(WebDataBinder binder)
{
StringTrimmerEditor trimmer = new StringTrimmerEditor(false);
binder.registerCustomEditor(String.class, trimmer);
}
}
...@@ -3,11 +3,13 @@ package de.deadlocker8.budgetmaster.authentication; ...@@ -3,11 +3,13 @@ package de.deadlocker8.budgetmaster.authentication;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configurers.FormLoginConfigurer;
import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.DefaultRedirectStrategy; import org.springframework.security.web.DefaultRedirectStrategy;
......
...@@ -119,3 +119,9 @@ function rgb2hex(rgb) ...@@ -119,3 +119,9 @@ function rgb2hex(rgb)
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]); return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
} }
function validateLoginForm()
{
let passwordInput = document.getElementById('login-password');
passwordInput.value = passwordInput.value.trim();
}
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<div class="card-title"> <div class="card-title">
<div id="logo-container" class="center-align"><@header.logo "logo" ""/></div> <div id="logo-container" class="center-align"><@header.logo "logo" ""/></div>
</div> </div>
<form action="<@s.url '/login'/>" method="post"> <form action="<@s.url '/login'/>" method="post" onsubmit="return validateLoginForm()">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/> <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
<input type="hidden" name="username" value="Default"> <input type="hidden" name="username" value="Default">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment