0

I am integrating SailsJS and Passport. I have a fairly simply controller but during the "process" method where I process the login I get the following error:

TypeError: Object #<Object> has no method 'authenticate'

You can see in the controller I am calling the passport.authenticate() method, according to docs this should exist.

LoginController.js

module.exports = {
  login: function(req, res) {
    res.view("login",{});
  },
  process: function(req, res) {

    passport.authenticate('local', function(err, user, info) {
      if( (err)||(!user) ) {
        return res.send({
          message: 'login failed'
        });
        res.send(err);
      }
      req.logIn(user, function(err) {
        if(err) res.send(err);
        return res.send({
          message: 'login successful'
        });
      });
    }) (req, res);
  },

  logout: function(req, res) {
    req.logOut();
    res.send('logout successful');
  }
};

How does the code know when to split into a line?

So I was learning on how to download files from the web using python but got a bit thrown by one part of the code.

Here is the code:

from urllib import request

def download_stock_data(csv_url):
    response = request.urlopen(csv_url)
    csv = response.read()
    csv_str = str(csv)
    lines = csv_str.split("\\n")
    dest_url = r"stock.csv"
    fx = open(dest_url, "w")
    for line in lines:
        fx.write(line + "\n")
    fx.close()

I don't quite understand the code in the variable lines. How does it know when to split into a new line on a csv file ?

4

1 回答 1

0

@idbehold 得到了这个,我在任何地方都不需要护照。

于 2015-03-07T12:33:40.200 回答