我使用带有 OAUTH 身份验证的 JHipster。我想创建一个用户,而不需要用户通过电子邮件激活帐户。我修改了UserService中的代码,认为通过将resetKey和resetDate设置为NULL,用户可以登录而无需激活步骤;创建时,activated
也设置为 true
。目前,在没有激活电子邮件的情况下创建的用户将获得:
{"error":"invalid_grant","error_description":"错误凭据"}
新用户登录的唯一方法是通过激活电子邮件并重置密码。
有什么方法可以在不执行此步骤的情况下创建用户吗?是否还有其他认证表需要修改?
非常感谢任何帮助。
编辑:
我在这里发现了这个错误 ```` protected void extraAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken 身份验证) 抛出 AuthenticationException { 对象盐 = null; if(this.saltSource != null) { 盐 = this.saltSource.getSalt(userDetails); }
if(authentication.getCredentials() == null) {
this.logger.debug("Authentication failed: no credentials provided");
throw new BadCredentialsException(this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
} else {
String presentedPassword = authentication.getCredentials().toString();
// PROBLEM IS INVALID PASSWORD!!!!
if(!this.passwordEncoder.isPasswordValid(userDetails.getPassword(), presentedPassword, salt)) {
this.logger.debug("Authentication failed: password does not match stored value");
throw new BadCredentialsException(this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
}
}
} ````
由于某种原因,我的密码无效并且盐为 NULL!我不知道为什么会这样。我看到的密码是我创建用户时使用的密码!
谢谢。
最佳答案
字段应为activated
和activationKey
。激活默认值为 false,参见User.java
。
关于oauth - JHipster 创建用户无需激活,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38841682/