2015-10-28 23 views
0

我正在使用Useraccounts包。我加入了一個名爲「名」,因此用戶可以在輸入符號名稱並登錄領域。但我想這樣的存儲配置文件中的字段的值流星Useraccounts。如何添加名稱字段並將其存儲在profile.name中

profile.name: "user" 

不是默認

name: "user" 

而且使用Useraccount時,我可以在服務器上調用Accounts.onCreateUser函數嗎?並希望在那裏改變它?對不起noob問題,但任何幫助讚賞謝謝。

回答

1

是的,您可以在服務器上使用Accounts.onCreateUser()。該功能需要一個options對象。假設你有:

options.profile.name = 'user'; 
當您創建帳戶

那麼你可以做:

Accounts.onCreateUser(function(options, user){ 
    user.profile = options.profile; 
    return user; 
}) 

這除了配置重點將使它成爲實際的用戶文檔。

+0

謝謝。但是我從ATCreateUserServer方法得到「無法設置未定義的屬性名」的異常。 – Zaya

+0

對不起,錯誤地認爲配置文件已經存在。看到更正。 –

+0

然後只要做'user.profile = {}; user.profile.name = options.name;' –

相關問題