2014-11-18 08:06:04 +01:00
|
|
|
var Promise = require("bluebird");
|
|
|
|
|
|
|
|
var strategies = [
|
|
|
|
{
|
|
|
|
name: "default",
|
|
|
|
description: "Default on or off Strategy."
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "usersWithEmail",
|
|
|
|
description: "Active for users defined in the comma-separated emails-parameter.",
|
|
|
|
parametersTemplate: {
|
|
|
|
emails: "String"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
function byName(name) {
|
|
|
|
return strategies.filter(function(s) {
|
|
|
|
return s.name === name;
|
|
|
|
})[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
getStrategies: function() {
|
|
|
|
return new Promise(function (resolve) {
|
|
|
|
resolve(strategies);
|
|
|
|
});
|
|
|
|
},
|
2014-11-25 15:28:08 +01:00
|
|
|
getStrategy: function(name) {
|
|
|
|
var strategy = byName(name);
|
|
|
|
if(strategy) {
|
|
|
|
return Promise.resolve(strategy);
|
2014-11-18 08:06:04 +01:00
|
|
|
} else {
|
|
|
|
return Promise.reject("strategy not found");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|