Change password from the server

how do I change the password (from the email + password credentiales) from the server? My understanding what that authClient is meant to be used in the client and that, in the server, I am expected to use auth.api.changePassword, as in:
const { user } = await auth.api.changePassword({
body: {
newPassword: parsedInput.newPassword,
currentPassword: parsedInput.oldPassword,
},
});
const { user } = await auth.api.changePassword({
body: {
newPassword: parsedInput.newPassword,
currentPassword: parsedInput.oldPassword,
},
});
` However, when doing that, I get:
error [APIError] {
status: 'UNAUTHORIZED',
body: undefined,
headers: {},
statusCode: 401
}
error [APIError] {
status: 'UNAUTHORIZED',
body: undefined,
headers: {},
statusCode: 401
}
I have also tried passing the session token in the changePassword method, with the same output (UNAUTHORIZED status). what am I missing? what is the suggested way to do this? Thank you 🙏🏻
Solution:
You need to pass the headers of the user making the request.
Jump to solution
3 Replies
Solution
Ping
Ping2mo ago
You need to pass the headers of the user making the request.
Risatoga
RisatogaOP2mo ago
aps, makes sense
KHRM
KHRM7d ago
ahh the headers thing always gets me

Did you find this page helpful?