diff --git a/.changeset/silly-rivers-compete.md b/.changeset/silly-rivers-compete.md new file mode 100644 index 00000000000..766607ce12a --- /dev/null +++ b/.changeset/silly-rivers-compete.md @@ -0,0 +1,5 @@ +--- +"@wso2is/myaccount": patch +--- + +Handle passwords containing special characters when updating password via my account. diff --git a/apps/myaccount/src/api/change-password.ts b/apps/myaccount/src/api/change-password.ts index 73b5843804c..1908fe512d9 100644 --- a/apps/myaccount/src/api/change-password.ts +++ b/apps/myaccount/src/api/change-password.ts @@ -45,12 +45,16 @@ export const updatePassword = (currentPassword: string, newPassword: string): Pr // See https://github.com/asgardio/asgardio-js-oidc-sdk/issues/45 for progress. // httpRequest.disableHandler(); + const username: string = [ + store.getState().authenticationInformation?.profileInfo.userName, + "@", + store.getState().authenticationInformation.tenantDomain + ].join(""); + // In case the password contains non-ascii characters, converting to valid ascii format. + const encoder: TextEncoder = new TextEncoder(); + const encodedPassword: string = String.fromCharCode(...encoder.encode(currentPassword)); + const requestConfig: AxiosRequestConfig = { - auth: { - password: currentPassword, - username: [ store.getState().authenticationInformation?.profileInfo.userName, "@", - store.getState().authenticationInformation.tenantDomain ].join("") - }, data: { Operations: [ { @@ -63,6 +67,7 @@ export const updatePassword = (currentPassword: string, newPassword: string): Pr schemas: [ "urn:ietf:params:scim:api:messages:2.0:PatchOp" ] }, headers: { + "Authorization": `Basic ${btoa(username + ":" + encodedPassword)}`, "Content-Type": "application/json" }, method: HttpMethods.PATCH,