                             </html>"
                     catch e
                         next e)()
-
+                        
 
     
     twitterCallback: (req, res, next) =>
         oa = new OAuth(
 	        "https://api.twitter.com/oauth/request_token",
 	        "https://api.twitter.com/oauth/access_token",
-	        conf.authenticationTypes.twitter.TWITTER_CONSUMER_KEY,
-	        conf.authenticationTypes.twitter.TWITTER_CONSUMER_SECRET,
+	        conf.auth.twitter.TWITTER_CONSUMER_KEY,
+	        conf.auth.twitter.TWITTER_CONSUMER_SECRET,
 	        "1.0",
-	        conf.authenticationTypes.twitter.TWITTER_CALLBACK,	
+	        conf.auth.twitter.TWITTER_CALLBACK,	
 	        "HMAC-SHA1"
         )
-        models.Token.get { type: 'oauth-process-key', key: req.cookies.oauth_process_key }, {}, db, (err, token) =>            
-            if not err
+        (Q.async =>               
+            try
+                token = yield models.Token.get { type: 'oauth-process-key', key: req.cookies.oauth_process_key }, {}, db
                 if token
                     oauth = token.value
                     oauth.verifier = req.query.oauth_verifier

                                    resp = JSON.parse response
                                    if resp.length and resp[0]?
                                        userDetails = @parseTwitterUserDetails resp[0]
                                        models.User.getOrCreateUser userDetails, {}, db, (err, user, token) =>
                                            res.clearCookie "oauth_process_key"
                                            res.cookie "userid", user._id.toString()

                                                    </script>
                                                    <body></body>
                                                </html>'
                                       ###             
                                    else
                                        utils.log response
                                        res.send "Invalid response."                            
                else
                    utils.log "No token"
                    res.send "Could not connect to Twitter."
            catch e
                next e)()               
                


