【问题标题】:Password update with Meteor Autoforms使用 Meteor Autoforms 更新密码
【发布时间】:2017-07-14 22:11:11
【问题描述】:

我正在尝试创建一个帐户页面,用户可以在其中更新他们的个人资料信息和/或更新他们的密码。我目前正在将其用于表单:

{{#autoForm collection="Meteor.users" doc=profile id="myAccount" type="update"}}
                        <fieldset>
                            <legend>My Account</legend>
                            {{> afQuickField name="username"}}
                            {{> afQuickField name="profile.firstName"}}
                            {{> afQuickField name="profile.lastName"}}
                            {{> afQuickField name="emails.0.address"}}
                            {{> afQuickField name="emails.0.verified" class="i-checks"}}
                            {{> afQuickField name="password"}}
                        </fieldset>
                        <button type="submit" class="btn btn-primary">Update</button>
                    {{/autoForm}}

据我了解,我需要使用 Accounts.setPassword 来更新用户密码。所以我想我必须为此使用一个钩子,但是 onSubmit 钩子不适用于类型更新。

用这种形式更新密码的最佳方法是什么?

【问题讨论】:

    标签: meteor passwords meteor-autoform


    【解决方案1】:

    这样的事情会起作用吗:https://github.com/aldeed/meteor-autoform#normal where contact form 是您的表单名称?

    AutoForm.hooks({
      contactForm: {
        onSubmit: function (insertDoc, updateDoc, currentDoc) {
          if (customHandler(insertDoc)) {
            this.done();
          } else {
            this.done(new Error("Submission failed"));
          }
          return false;
        }
      }
    });
    

    【讨论】:

    • onSubmit 不适用于 type="update"。如果我更改提交类型,您的建议有效。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2020-10-25
    • 1970-01-01
    • 2020-12-20
    • 1970-01-01
    • 2016-04-05
    • 1970-01-01
    • 2021-01-13
    • 2020-05-19
    相关资源
    最近更新 更多