【问题标题】:Where are sails.helpers functions coming from in the default sails web app默认sails web应用程序中的sails.helpers函数来自哪里
【发布时间】:2019-02-19 07:31:18
【问题描述】:

我很好奇sails.helpers.x.y() 函数在sails 附带的示例网络应用程序中的来源。

运行sails new test-project 后,选择网络应用并环顾四周,我注意到许多文件都在调用sails.helpers.passwords.hashPassword() 之类的函数。

但是,在查看 helpers 文件夹时,唯一的文件是 send-template-email,没有任何类似于哈希密码的函数。

我已经阅读了有关sails 辅助函数here 的文档,它没有提到任何默认的辅助函数,例如hashPassword。我也在vscode中调试了一下,发现确实定义了sails.helpers.passwords.hashpassword(),但是我搜索源码的时候到处都找不到。

有人知道这些助手来自哪里吗?

作为参考,我调试到 hashPassword() 调用的代码部分位于 signup.js 中:

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'
    }:{}))

【问题讨论】:

    标签: node.js sails.js


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-05
      • 1970-01-01
      • 2011-09-18
      • 1970-01-01
      • 2011-06-18
      • 2012-04-24
      相关资源
      最近更新 更多