title: OAuth2 - handle password change in Spring Security
body: <p>I'm implementing OAuth2 for my REST Service (password grant type) with help of Spring security module. I' using postgreSQL as my Token Store. All works fine, but I need to add the possibility to change user password. If user change his password old token should be deleted/forgotten. </p>
  
  <p>I implement this feature using JdbcTokenStore Spring service:</p>
  
  <pre><code>public void updatePassword(User user, String newPassword) {
      ...
      // Update password in database
  
      clearUserTokens(user.getUsername());
  }
  
  private void clearUserTokens(String userName) {
      Collection&lt;OAuth2AccessToken&gt; tokens = jdbcTokenStore.findTokensByUserName(userName);
      tokens.stream().forEach(jdbcTokenStore::removeAccessToken);
  }
  </code></pre>
  
  <p>Is this approach correct? Is there any standard way of handling that kind of situations?</p>