title: set session attribute after login
body: <p>I need to set ID of a user as a session attribute after login using Java EE form login module.</p>
  
  <p>Right now, after login, I send another HTTP request, which sets the ID as a session attribute, but I need to do it in one step. What is the best way to do it?</p>
  
  <p>login module configuration in standalone.xml:</p>
  
  <pre><code>&lt;login-module code="com.MyLoginModule" flag="required"&gt;
      &lt;module-option name="dsJndiName" value="java:/PostgresDS"/&gt;
      &lt;module-option name="principalsQuery" value="select password from appuser where email=?"/&gt;
      &lt;module-option name="rolesQuery" value="select 'AUTHENTICATED', 'Roles' from appuser where email=?"/&gt;
      &lt;module-option name="hashAlgorithm" value="custom"/&gt;
  &lt;/login-module&gt;
  </code></pre>
  
  <p>Additional request after login (RESTEasy):</p>
  
  <pre><code>@GET
  @Path("/web")
  @Produces(MediaType.APPLICATION_JSON)
  public User getUser(@Context HttpServletRequest hsr) throws MyRuntimeException{
      User u;
      HttpSession session = hsr.getSession();
      u = um.getUserByMail(hsr.getUserPrincipal().getName());
      session.setAttribute("userId", u.getId());
      return u;
  }
  </code></pre>
  
  <p>MyLoginModule:</p>
  
  <pre><code>public class MyLoginModule extends DatabaseServerLoginModule {
  @Override
  public String createPasswordHash(String username, String password, String digestOption){code}
  }
  </code></pre>