【问题标题】:Syncano User Management Profile Update ErrorSyncano 用户管理配置文件更新错误
【发布时间】:2016-01-03 23:18:27
【问题描述】:

我尝试使用 Syncano 用户管理系统为我的应用程序实现用户注册。我能够使用以下 JS 库代码成功创建新用户:

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 修补 https://api.syncano.io/v1/instances/INSTANCE/classes/user_profile/objects/26/ 404 (NOT FOUND) user.service.js:77 错误:{"detail":"Not found"}"

有什么想法吗?

【问题讨论】:

  • 调查这个。我没有收到 404,但确实收到了不同的错误。我可能需要重做我的示例。

标签: javascript user-management syncano


【解决方案1】:

看起来示例代码有问题(遗憾的是我写的)。

用户创建后返回的对象有一个id字段用于user对象,还有一个profile.id用于修改user_profile对象。

该行需要改为这个

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

我还要注意当前系统中的另一个警告 - 您必须首先在 user_profile 类上将 other permissions 设置为 read

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

希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 2012-08-31
    • 2020-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-27
    • 2023-03-30
    • 2017-09-04
    • 2012-09-20
    相关资源
    最近更新 更多