I’m trying to run functions insertOne, updateOne from web client (so can pass registration variables like nickname and comments), not via a registerUser (create) realm server trigger with this code:
await realmapp.emailPasswordAuth.registerUser({ email, password });
//Immediately login the new user
//(to go past 'pending' in realm console)
const newUsercredentials = Realm.Credentials.emailPassword(email, password);
const loggedInNewUser = await realmapp.logIn(newUsercredentials);
console.log('new
user just registered : ', loggedInNewUser);
const newUser = await users.insertOne({ id:
loggedInNewUser.id });
await users.updateOne({ id:
loggedInNewUser.id },
{ $set:
{
"custom_data.active": true,
"custom_data.description":{level: '',
comment: ''
},
"custom_data.alternate_email": "",
"custom_data.nickname": "",
"custom_data.ownerOf": [],
"custom_data.memberOf": []
}
});
In http headers:
Request id for the newly created user is correct:
63366590c70e5740bff597fa
but I get Response:
error "invalid session: No user found for session for user id '633664ccc59dec10f25094ef '
or
error "invalid session: access token expired"
error_code "InvalidSession"
i.e. response indicates wrong user id or access/refresh token expired
Why is this happening? What can I do to ensure a valid user session and complete the creation of the necessary user document and associated custom_data without using server side triggers that depend on server side functions? thanks …