narrow-dusk-31843
12/09/2022, 10:40 PMconst get = id => sdk.getIdentity({ id });
In addition, I'm able to list things out by calling:
const list = makePaging(page => sdk.listIdentitiesRaw({ page }));
The problem is when I want to update anything in a user's identity. Here's my function:
const updateUsername = async (id, username) => {
const adminUpdateIdentityBody = { traits: { username } };
const current = await get(id);
if ('traits' in adminUpdateIdentityBody) {
adminUpdateIdentityBody.traits = { ...current.traits, ...adminUpdateIdentityBody.traits };
}
return sdk.updateIdentity({ id, adminUpdateIdentityBody }).catch(err => err.response.json());
};
Here's sample local data from a fake user:
{
created_at: 2022-12-09T02:11:50.965Z,
credentials: {
oidc: {
config: undefined,
created_at: 2022-12-09T02:11:50.980Z,
identifiers: [Array],
type: 'oidc',
updated_at: 2022-12-09T02:11:50.980Z,
version: 0
},
password: {
config: undefined,
created_at: 2022-12-09T02:11:51.009Z,
identifiers: [Array],
type: 'password',
updated_at: 2022-12-09T02:11:51.009Z,
version: 0
}
},
id: 'fake-uuid',
metadata_admin: undefined,
metadata_public: undefined,
recovery_addresses: undefined,
schema_id: 'user-v1',
schema_url: 'some-kratos-schema-url',
state: 'active',
state_changed_at: 2022-12-09T02:11:50.963Z,
traits: {
secondaryEmails: [ '<mailto:fake4@gmail.com|fake4@gmail.com>' ],
tos: true,
username: 'fake'
},
updated_at: 2022-12-09T02:11:50.965Z,
verifiable_addresses: undefined
here's what I get when i try to change the username via
auth.updateUsername( '3a732e1a-9f8d-4006-bd8b-5d9e82f5616a', 'fakeee')
result:
{
error: {
code: 400,
status: 'Bad Request',
reason: 'Unable to decode HTTP Request Body because its HTTP Header "Content-Length" is zero.',
message: 'The request was malformed or contained invalid parameters'
}
}
magnificent-energy-493
narrow-dusk-31843
12/13/2022, 6:32 PMnarrow-dusk-31843
12/13/2022, 6:32 PMsdk.updateIdentity({ id, adminUpdateIdentityBody }).catch(err => err.response.json());