Hi im trying to allow users to reset their passwords using my API. So I followed the exact step which the casdoor client does, i.e
- Get user details using /api/get-email-and-phone
- Send OTP using /api/send-verification-code
- Update the password using /api/set-password
However I am getting following error when trying to call /set-password
"data": {
"status": "error",
"msg": "Missing parameter",
"sub": "",
"name": "",
"data": null,
"data2": null
}
When I check the code I realized i need to set the session according to following code from set-password handler
if code != c.GetSession("verifiedCode") {
c.ResponseError(c.T("general:Missing parameter")) <-- fails here
return
}
So I tried to add a session manually using the API, ( This was added before sending the otp and session Id was also used for sending otp )
const user = await this.getEmailAndPhone(mobileOrEmail, ''); // call /api/get-email-and-phone
sessionId = nanoid();
const session = await this.casdoorClient.sdk.addSession({
owner: this.casdoorClient.casdoorConfig.orgName,
name: user.name,
application: this.casdoorClient.casdoorConfig.appName,
createdTime: new Date().toISOString(),
sessionId: [sessionId],
})
Then I used the sessionId for subsequent requests
const res = await this.casdoorClient.http.post('/set-password', formData, {
headers: {
'Cookie': `casdoor_session=${sessionId}`,
}
});
However I am still getting the same error, Is there something wrong im doing here ?
Thanks
