无法使用电子邮件和密码进行身份验证

时间:2015-05-02 07:20:24

标签: meteor meteor-accounts

我正在尝试使用自定义登录表单对用户进行身份验证。我设计了表单,我正在尝试验证这样的用户:

Template['account.login'].events
'submit #login-form': (e, t) ->
e.preventDefault()

Meteor.loginWithPassword(
  t.find('#login_username').value,
  t.find('#login_password').value,
  (err)->
    console.log(err)
)
return false

相关模板(在JADE中 - 抱歉):

form.smart-form.client-form#login-form(novalidate)
    fieldset
        section
            label.input
                input#login_username(type="text", name="username")
        section
            label.input
                input#login_password(type="password", name="password")
    footer
        button.btn.btn-primary(type="submit", id="login.btn.login") Login

从我在网上找到的资源中,这是正确的。但是,我在服务器上抛出了这个异常:

Exception while invoking method 'login' Error: Match error: Failed Match.Where validation in field username in field user.username

1 个答案:

答案 0 :(得分:0)

您忘记添加标签,Meteor.loginWithPassword()正在模板事件之外运行。将您的coffeescript代码粘贴到http://js2.coffee/,您就会立即看到它。

相关问题