0
我想将用户的email_id用作用户名,但由于某种原因,当我尝试通过email_id进行身份验证时,它不起作用,它将被重定向到错误页面。无法通过email_id在spring security中验证用户
这里是我实现安全配置的
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication().dataSource(dataSource).passwordEncoder(passwordEncoder())
.usersByUsernameQuery(
"select email_id,password,enabled from users where email_id = ?")
.authoritiesByUsernameQuery(
"select email_id,'USER_ROLE' from users where email_id = ?");
}
PS:我试图通过'?'
思维EMAIL_ID周边?
不正确地传递。
登录页面JSP
<form method="post" th:action="@{/login}" name="f">
<fieldset>
<%-- <div th:if="${param.error}" class="alert alert-error">
Invalid username and password.
</div>
<div th:if="${param.logout}" class="alert alert-success">
You have been logged out.
</div> --%>
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
<div class="margin-top-10 form-group">
<input class="form-control input-lg" type="text" id="username" name="username" placeholder="Username" />
</div>
<div class="margin-top-10 form-group">
<input class="form-control input-lg" type="password" id="password" name="password" placeholder="Password"/>
</div>
<div class="margin-top-10 form-actions form-group">
<button type="submit" class="btn btn-default btn-primary">Login</button>
<a class="register-link">Register</a>
</div>
</fieldset>
</form>
帖子错误.. –
它不会抛出任何错误,它只是获取重定向到/ login?错误页面配置为无效凭据 –
发布您的登录页面还请确保您实际上已加密d数据库中的密码。 –