After a user is created, I can assign that user to a role with this bit of code in my 'after save' hook:
let roleMap = {
principalType: app.models.RoleMapping.USER,
principalId: context.instance.id
};
role.principals.create(roleMap, function (err, principal) {
if (err) throw err;
});
What I am having issues doing is changing the role assigned to a user. Originally I thought replacing 'create' with 'createOrUpdate' or 'upsertWithWhere' might do the trick, but loopback tells me those functions don't exist on 'principals'.
Can someone point me in the right direction?
Thanks!
--Lisa