title: Backbone, Node, Session validation, my method working, but tell me whether it is correct or not
body: <p>I used this at the beginning : </p>
  
  <pre class="lang-js prettyprint-override"><code>var app = express.createServer(
    express.cookieParser(),
    express.session({ secret: 'somesecretword' })
  );
  </code></pre>
  
  <p>Below code is a sample code to get user details with uname as the key.</p>
  
  <p>I call this code from backbone model's url, by calling model.fetch().</p>
  
  <pre class="lang-js prettyprint-override"><code>app.get('/user/:uname/', function (req, res) {
  
    var uname=req.params.uname;
    if(!req.session.user)   // check if logged in
    res.send("Not Logged In");
  
    return UserModel.find({uname : uname},function(err, user) {
      if (!err) {
        return res.send(user);
      } else {
        return res.send(err);
      }
    });
  });
  </code></pre>
  
  <p>So, here I wrote the code for validating session directly in the above get method.</p>
  
  <p>What if I have many such methods? Do I have to write the same thing in every method, or is there any controller in Node that does this work?</p>
  
  <p>For example, show me a controller that validates for the paths "/user" , means "/user/anythinghere/" should be validated automatically or show me some other better way.</p>