2013-12-11 128 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