Reputation: 83
I am usgin JHipster with OAUTH authentication. I would like to create a user without the user activating the account via email. I have modified the code in the UserService thinking that by setting the resetKey and resetDate to NULL, the user can login without the activation step; the activated
is also set to true
upon creation. Currently, a user created without the activation email gets:
{"error":"invalid_grant","error_description":"Bad credentials"}
The only way the new user can login is via the Activation email and resetting the password.
Is there any way a user can be created without this step? Is there another authentication table to modify?
Any help is greatly appreciated.
EDIT:
I found the bug here ``` 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"));
}
}
} ```
For some reason my password is not valid and salt is NULL! I have no idea why this is the case. The password I see is the one I created the user with!
Thanks.
Upvotes: 2
Views: 1488
Reputation: 368
In UserService.registerUser make:
newUser.setActivated(true);
This will make the user active upon register. skipping the email verification.
Upvotes: 1
Reputation: 16294
Fields should be activated
and activationKey
. Activated default value is false, see User.java
.
Upvotes: 1