I'm working on adding password reset functionality to users on my Apostrophe CMS installation. I'm using this code to find the user by email address and create a new token for later use: (in lib/modules/apostrophe-users/index.js)
module.exports = {
construct: function(self, options) {
self.route('post', 'send-reset-token', function (req, res) {
var email = req.body.email;
var usersModule = self.apos.modules['apostrophe-users'];
var userList = usersMods.find(req, {email: email}, {permissions: false});
userList.toArray(function (err, arr) {
if (arr.length > 0) {
//Create token
}
});
}
}
}
But, when this request is made from a non-logged-in session (which is the point of the reset), the list of users is blank. I thought (from reading documentation) that setting the options.permissions param to false, it would get the user without checking for permissions first, but it doesn't seem to be working. I can get the user correctly when I make this call when logged in as admin.
Is there something else I need to do to find this user on the server side without the requesting person having permission to see users?