trailsjs / sails-auth

Passport-based User Authentication system for sails.js applications. Designed to work well with the sails-permissions module.
https://www.npmjs.org/package/sails-auth
MIT License
266 stars 141 forks source link

Extend / Override Protocol #123

Open dottodot opened 8 years ago

dottodot commented 8 years ago

I'm wanting to make some changes to the way the local protocol works in particular the login but can't work it out. In my app api > services > protocols > local.js I would have assumed something like the following would have giving me the ability to override it but it doesn't do anything

var _ = require('lodash');
var _super = require('sails-permissions/api/services/protocols/local');

function protocols () { }

protocols.prototype = Object.create(_super);
_.extend(protocols.prototype, {

  login: function (req, identifier, password, next) {
    console.log(req);
  }

});

module.exports = new protocols();
mneil commented 7 years ago

I would also like to see this added. I've dug through the code now for a few hours and as far as I can tell there actually isn't a way to add any other passport strategies than the ones supported by the plugin. The "et al" in the docs is overstated.

The issue is that all passport strategies require a callback.

While you can define the protocol to use it seems impossible to change the services protocol at runtime before the strategy is instantiated but after the config is loaded.

fulminant commented 6 years ago

I have the same problem.