2015-10-06 70 views
2

我试图使用Syncano用户管理系统实现用户注册我的应用程序。我可以使用下面的JS库代码成功地创建一个新用户:Syncano用户管理配置文件更新错误

var sync = new Syncano({ apiKey: 'API_KEY', instance: 'INSTANCE' }); 
sync.user().add(signUp).then(function(res){ 
    console.log(res); 
}).catch(function(err) { 
    console.log(err); 
}); 

然后我试图通过以下对配置文件字段添加到我的用户代码在这里找到:https://www.syncano.io/user-management-for-your-apps/#adding-fields

var sync = new Syncano({ apiKey: 'API_KEY', instance: 'INSTANCE' }); 
sync.user().add(signUp).then(function(res){ 
    var instance = new Syncano({ 
    apiKey: API_KEY, 
    instance: INSTANCE_NAME, 
    userKey: res.user_key 
    }); 
    instance.class('user_profile').dataobject(res.id).update({firstName: 'First', lastName: 'Last'}); 
}).catch(function(err) { 
    console.log(err); 
}); 

当我在第一个的.then()语句中进行第二个API调用,我得到这个错误:

"api.syncano.io/v1/instances/INSTANCE/classes/user_profile/objects/26/:1 PATCH https://api.syncano.io/v1/instances/INSTANCE/classes/user_profile/objects/26/ 404 (NOT FOUND) user.service.js:77 Error: {"detail":"Not found"}"

任何想法?

+0

看着这个。我没有得到404,但我确实得到了一个不同的错误。我可能需要重做我的例子。 –

回答

1

看起来像示例代码有问题(可悲的是我写的)。

被用户创建后返回的对象具有用于user对象的id字段,以及profile.id修改user_profile对象。

线必须是这个,而不是

instance.class('user_profile').dataobject(res.profile.id).update({firstName: 'First', lastName: 'Last'}); 

有一个在当前系统中另一个需要注意的,我也会让一个音符 - 你必须先设置other permissionsreaduser_profile类。

这将最终在平台中更改为默认read

希望这会有所帮助!