Reputation: 101
I am curious as to where sails.helpers.x.y() functions are coming from in the example web app that comes with sails.
After running sails new test-project
, selecting the web app and looking around a bit I noticed that many files are calling functions like sails.helpers.passwords.hashPassword()
.
However when looking in the helpers
folder, the only file there is send-template-email
with nothing resembling a function to hash passwords.
I've read the docs on sails helper function here and it doesn't mention any default helper functions like hashPassword. I have also gone through the debugger in vscode and found that sails.helpers.passwords.hashpassword()
is indeed defined, but I can't find it anywhere when I search through the source.
Does anybody know where these helpers are coming from?
For reference the part of the code that I debugged to get to the hashPassword()
call was in signup.js
here:
var newUserRecord = await User.create(_.extend({
emailAddress: newEmailAddress,
password: await sails.helpers.passwords.hashPassword(inputs.password),
fullName: inputs.fullName,
tosAcceptedByIp: this.req.ip
}, sails.config.custom.verifyEmailAddresses? {
emailProofToken: await sails.helpers.strings.random('url-friendly'),
emailProofTokenExpiresAt: Date.now() + sails.config.custom.emailProofTokenTTL,
emailStatus: 'unconfirmed'
}:{}))
Upvotes: 1
Views: 1922
Reputation: 1078
They come from the sails-hook-organics package, check here the password methods, https://github.com/sailshq/sails-hook-organics/blob/a27db6c93e7333f5036a54ceb13a2e3b3fa0ae26/OTHER-USEFUL-METHODS.md
Upvotes: 4