     res.redirect '/'
   twitterAuthCallback: (req, res) ->
     # Create Product Grunt user if doesn't exist
-    twitterId = req.user.twitterId
+    twitterId = +req.user.id
     User.findOne twitterId: twitterId, (err, data) ->
       if !data
-        # Add user data
-        req.user.twitterId = req.user.id
-        req.user.twitterUsername = req.user.username
-        photoURL = req.user.photos[0].value
-        req.user.twitterProfilePicture = photoURL.split('_normal').join('')
-        req.user.name = req.user.displayName
-        req.user.bio = req.user._json.description
+        # Get new uid
+        User.find().sort(uid:-1).limit(1).exec (err, data) ->
+          newUid = data[0].uid + 1
 
-        newUser = new User
-          twitterId: req.user.twitterId
-          twitterUsername: req.user.twitterUsername
-          twitterProfilePicture: req.user.twitterProfilePicture
-          name: req.user.name
-          bio: req.user.bio
-          uid: req.user.uid
+          # Add user data
+          req.user.twitterId = req.user.id
+          req.user.twitterUsername = req.user.username
+          photoURL = req.user.photos[0].value
+          req.user.twitterProfilePicture = photoURL.split('_normal').join('')
+          req.user.name = req.user.displayName
+          req.user.bio = req.user._json.description
+          req.user.uid = newUid
 
-        console.log req.user
+          newUser = new User
+            twitterId: req.user.twitterId
+            twitterUsername: req.user.twitterUsername
+            twitterProfilePicture: req.user.twitterProfilePicture
+            name: req.user.name
+            bio: req.user.bio
+            uid: req.user.uid
 
-        newUser.save (err, newUserSave) ->
-          res.send '<header><meta http-equiv="refresh" content="0; url=/" /></header>'
+          newUser.save (err, newUserSave) ->
+            res.send '<header><meta http-equiv="refresh" content="0; url=/" /></header>'
       else
         # User has data, add it
-        console.log data
         req.user.twitterId = data.twitterId
         req.user.twitterUsername = data.twitterUsername
         req.user.twitterProfilePicture = data.twitterProfilePicture


        res.send '<header><meta http-equiv="refresh" content="0; url=/" /></header>'
  about: (req, res) ->
    res.render 'about'
  user: (req, res) ->
    res.render 'user'
  404: (req, res) ->
    res.status(404).send('404')



routes =
  index: (req, res) ->
    res.render 'index',
      user: req.user
  login: (req, res) ->
    if req.isAuthenticated()
      res.redirect '/'
