I tried to implement a user sign up for my app using the Syncano User Management system. I was able to successfully create a new user using the following JS Library code:
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);
});
Then I tried to add profile fields to my user by following the code found here: 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);
});
When I make the second API call inside the .then() statement of the first, I get this error:
"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"}"
Any ideas?
Looks like there is a problem with the sample code (that sadly I wrote).
The object that is returned after user creation has an id
field for the user
object, and a profile.id
to modify the user_profile
object.
The line needs to be this instead
instance.class('user_profile').dataobject(res.profile.id).update({firstName: 'First', lastName: 'Last'});
There is another caveat in the current system that I will also make a note of - you must first set the other permissions
to read
on the user_profile
class.
This will eventually be changed in the platform to default to read
.
Hope this helps!