用户在Meteor中使用AutoForm注册

时间:2015-08-01 22:04:37

标签: meteor meteor-accounts meteor-autoform

我正在尝试使用Account和AutoForm包进行注册。帐户包给我们创建,登录,验证用户,安全密码等。另一方使用autoform包创建表单,具有冷字段验证和显示错误功能。根据一些文档,我知道我必须在内部服务器方法中创建。我做了同样的事情,但在创建用户后,Meteor.user()给出 null (即用户未登录)。这是我的示例代码:

两者/架构/ schema.js

MyUser = new SimpleSchema({
    fullname : {
        type: String
    },
    email: {
        type: String,
        regEx: SimpleSchema.RegEx.Email,
        autoform: {
            afFieldInput: {
                type: "email"
            }
        }
    },
    password : {
        type: String,
        autoform: {
            afFieldInput: {
                type: "password"
            }
        }
    }
});

的客户机/ home.html做为

<template name="SignUp">
     {{#autoForm schema='MyUser' id='signUp' type='method' meteormethod='myCreateUser'}}
         {{> afQuickField name='fullname' class="form-control"}}
         {{> afQuickField name='email' class="form-control"}}
         {{> afQuickField name='password' class="form-control"}}
         <button type="submit">Sign Up</button>
    {{/autoForm}}
</template>

服务器/方法/ methods.js

Meteor.methods({
    myCreateUser : function(doc){
        console.log(doc);
        var newUser = Accounts.createUser(doc);
    }
});

我的方法是使用用户身份验证和autoform包的帐户包进行验证并显示错误。我知道在服务器和客户端之间发送原始密码不是一个好主意。

那么,任何人都可以帮我解决这两个方案的问题吗?

0 个答案:

没有答案
相关问题