2017-12-30 31 views
0

Meteor.users()에 새 사용자를 삽입하는 버튼이 있습니다. (버튼을 클릭 한 후) Meteor.users()에 새 필드를 추가하려면 어떻게합니까?

Meteor.methods({ 
    'addUser': function(user) { 
     return Accounts.createUser(user) 
    } 
}) 

그리고 클라이언트

가 : 서버에서

나는이 방법이 위의 코드를 사용하여

var newUser = { 
      email: t.find('#email').value, 
      password: t.find('#pwd').value, 
      profile: { name: t.find('#name').value, group: t.find('#userType').value }, 
      roles: checkedRoles // I can successfully console.log(checkedRoles) which is an array of strings. 
     } 

     Meteor.call('addUser', newUser, function(error){ 
      if(error){ 
       sweetAlert(error) 
      } else { 
       sweetAlert('User Successfully Added') 
      } 
     }) 

, 사용자가 추가됩니다 있지만없이 roles 들.

제 질문은 새로 추가 한 사용자에게 roles 필드를 어떻게 추가 할 수 있습니까?

+0

당신이 Alanning를 시도 : 다음

meteor add alanning:roles

(서버 측 방법)

? – Orozcorp

+0

이것이 https://stackoverflow.com/questions/43436117/how-to-read-the-roles-array-from-users-collection의 복제라고 의심됩니다. – ghybs

+0

@Orozcorp 예, alnning : roles 패키지를 사용하고 있습니다. – sourceplaze

답변

3

사용 alanning:roles 패키지 : 역할 패키지 :

const userId = Accounts.createUser(user);

Roles.addUsersToRoles(userId, user.roles);