title: Redirect to user dashboard after successful login
body: <p>I'm trying to redirect to my user-dash.html page after the user is successfully logged in.</p>
  
  <p>I've already tried using res.redirect() and got an error about not setting headers after they've been sent to the client.</p>
  
  <p>public.index.js:</p>
  
  <pre><code>// when the login from is submitted:
  
      $("#loginForm").submit(function(e) {
          e.preventDefault();
          let username = $("#GET-username").val();
          let password = $("#GET-password").val();
          let userInfo = {username, password};
          let settings = {
              url:"/auth/login",
              type: 'POST',
              contentType: 'application/json',
              data: JSON.stringify(userInfo),
              success: function(data) {
                  console.log('successfully logged in');
                  localStorage.setItem("authToken", data.authToken);
                  localStorage.setItem("currentUser", username);
                  user = username;
                  console.log(data);
                  },
              error: function(err) {
                  console.log(err);
              }
          };
          $.ajax(settings);
      })
  </code></pre>
  
  <p>auth/router.js:</p>
  
  <pre><code>// The user provides a username and password to login
  router.post('/login', localAuth, (req, res) =&gt; {
    const authToken = createAuthToken(req.user.serialize());
    res.json({authToken});
  });
  
  const jwtAuth = passport.authenticate('jwt', {session: false});
  </code></pre>
  
  <p>right now, when submit is clicked, the user is successfully logged in but nothing happens i.e. the user isn't redirected to their dashboard.</p>