使用sails.js确认密码

mrc*_*cni 0 javascript node.js sails.js

我想在帆0.10.0-rc9中设置密码确认.这是一个新用户注册.当我在两个字段中使用相同的密码时,控制台确认它正在抓取相同的密码,然后吐出它们不匹配的错误.我想知道我错过了什么......

model - user.js - 看起来像 https://github.com/mrcn/C_Express/blob/master/api/models/User.error.js

module.exports = {
  schema: true,
  attributes: {
    name: {
      type: "string",
      required: true
    },
    email: {
      type: "string",
      email: true,
      required: true,
      unique: true
    },
    encryptedPassword: {
      type: "string"
    },
    toJSON: function() {
      var obj = this.toObject();
      delete obj.password;
      delete obj.confirmation;
      delete obj.encryptedPassword;
      delete obj._csrf;
      return obj;
    }
  },
  beforeCreate: function (values, next) {
      console.log("Called beforeCreate User ");
      console.log(values);
    if(!values.password || values.password != values.confirmation) {
      console.log("\n if statement call \n");
      return next({
        err : ["password dont match."]
      });
    }
  }
};
Run Code Online (Sandbox Code Playgroud)

表单如下所示:https: //github.com/mrcn/C_Express/blob/master/views/user/new.ejs

  <input type="text" class="form-control" placeholder="your name" name="name" required />

  <input type="email" class="form-control" placeholder="email address" name="email" data-parsley-trigger="change" required />

  <input type="password" class="form-control" placeholder="password" name="password" required />

  <input type="password" class="form-control" placeholder="confirmation" name="confirmation" required />
  <br />

  <input type="submit" class="btn btn-lg btn-primary btn-block" value="Create Account" />
  <input type="hidden" name="_csrf" value="<% _csrf %>" />
Run Code Online (Sandbox Code Playgroud)

当我对所有东西使用随机"wer"时,控制台记录"

Called beforeCreate User
{ name: 'wer',
  email: 'wer@wer.com',
  password: 'wer',
  confirmation: 'wer',
  _csrf: '',
  id: null }

 if statement call

{ err: [ 'password dont match.' ] }
Run Code Online (Sandbox Code Playgroud)

sgr*_*454 5

password两个地方的拼写可能相同吗?:P

if(!values.password || values.pasword != values.confirmation) {
                                ^oops
Run Code Online (Sandbox Code Playgroud)