2015-04-16 74 views
1

Im使用alanning-roles包和Meteor.method創建一個包含角色的賬戶,但賬戶被創建爲沒有任何角色。具有角色的賬戶MeteorJS

瀏覽器控制檯拋出Internal 505 error和服務器控制檯拋出invalid createUser Method.

這是我的方法。

Meteor.methods({ 
createUser:function(password,email,username){ //Normal Account 
    var rol = "Normal", 
     account = Accounts.createUser({ 
       email:email, 
       password:password, 
       username:username 
      }); 
     console.log(account) //returns id wich i need to add the user to the rol 
     Roles.addUsersToRoles(account, rol); 
     return account; 
    } 
}) 

並且像在事件處理程序上那樣調用它。

Meteor.call('createUser',"example123","[email protected]","example",function(error,account){ 
if(error){ 
    console.log(error.reason) 
    }else{ 
    console.log("user created") 
    } 
}) 

回答

1
Internal 505 error //this means something get wrong on the server, so the Meteor.call is ok. 

而且服務器的方法是好的,但你需要用的ROL一個數組裏面,像這樣。

var rol = ["Normal"] 

角色字段就像Accounts-Package上的電子郵件字段。

+0

謝謝你的答案,讓我試試更新:謝謝ethan它的任何理由爲什麼它應該是一個數組而不是一個字符串? –

相關問題