2013-12-11 141 views
0

当我添加新用户并打开接收到的验证电子邮件中的链接时,新用户已登录但无法更改密码。当我去“更改密码”时,我将“当前密码”留空,输入密码,然后单击“更改密码”,出现“匹配失败”错误。新用户无法在流星中更改密码

用户与Meteor.call从客户端创建到以下方法:

Meteor.methods({ 
    createUser: function(user) { 
    var userID = Accounts.createUser({ 
     username: user.username, 
     email: user.email, 
     profile: { 
     firstName: user.firstName, 
     lastName: user.lastName, 
     } 
    }); 
    Accounts.sendVerificationEmail(userID); 
    } 
}); 

我有Accounts.config和Accounts.ui.config以下设置:

Accounts.ui.config({ 
    passwordSignupFields: 'USERNAME_AND_EMAIL' 
}) 

Accounts.config({ 
    forbidClientAccountCreation: false, 
    sendVerificationEmail: true 
}) 

谢谢:-)

回答

2

你为什么要把当前密码留空?

创建帐户时,您必须指定一个密码,否则它将被视为空。

尝试通过password: ""时创建它,如果你打算这样改变它。

如果您希望他们在验证帐户后输入密码,我会建议您编写一个方法来更改它。类似这样的:

Meteor.methods('changeMyPassword':function(newPassword) { 
    Accounts.setPassword(this.userId, newPassword); 
}); 

帐户验证电子邮件的目的是您创建一个具有指定密码的帐户,并在您创建帐户后验证它。

如何使用示例Accounts.createUser

+0

案例是空密码。我已经尝试过使用'password:“”',但结果相同。但你的答复仍然是一个答案:-)谢谢! – react0r

+0

does Accounts.setPassword(this.userId,newPassword);仍然存在于流星?我有未定义的功能,当我叫它 – Genjuro

+0

@Genjuro是它仍然存在(https://github.com/meteor/meteor/blob/devel/packages/accounts-password/password_server.js#L327-L342)。确保你已经添加了'accounts-password' – Akshat