I am trying to set the value of setIs_active to true when user registration gets complete but I have taken method findByEmail as optional not I am not able to set the value to true.Can ayone tell me what is the reason for that?
public String confirmAccount(String confirmationToken)
{
ConfirmationToken token = confirmationTokenRepository.findByConfirmationToken(confirmationToken);
if(token != null)
{
Optional<User> user = userRepository.findByEmail(token.getUser().getEmail());
user.setIs_active(true);//here I am getting error
userRepository.save(user);//here I am getting error
return "Your account is activated" ;
}
else
return "Error ! Please try again";
}