JHipster创建用户而无需激活

时间:2016-08-09 03:44:30

标签: oauth jhipster

我是使用OAUTH身份验证的用户JHipster。我想在没有用户通过电子邮件激活帐户的情况下创建用户。我修改了UserService中的代码,认为通过将resetKey和resetDate设置为NULL,用户无需激活步骤即可登录;创建时activated也设置为true。目前,没有激活电子邮件创建的用户获得:

{"error":"invalid_grant","error_description":"Bad credentials"}

新用户登录的唯一方法是通过激活电子邮件并重置密码。

如果没有这一步,是否可以创建用户?是否有另一个要修改的身份验证表?

非常感谢任何帮助。

编辑:

我在这里发现了这个错误 ``` protected void additionalAuthenticationChecks(UserDetails userDetails,UsernamePasswordAuthenticationToken authentication)throws AuthenticationException {     Object salt = null;     if(this.saltSource!= null){       salt = 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"));
  }
}

} ```

由于某种原因,我的密码无效且salt为NULL!我不知道为什么会这样。我看到的密码是我创建用户的密码!

感谢。

2 个答案:

答案 0 :(得分:1)

字段应为activatedactivationKey。激活的默认值为false,请参阅User.java

答案 1 :(得分:0)

在UserService.registerUser make:

<强> newUser.setActivated(真);

这将使用户在注册时处于活动状态。跳过电子邮件验证。

相关问题