Skip to content

Commit

Permalink
Merge pull request #6839 from Yasasr1/my-account-passwd-update
Browse files Browse the repository at this point in the history
Handle passwords containing special characters when updating password via my account
  • Loading branch information
Yasasr1 authored Aug 29, 2024
2 parents 040c1e4 + 9f05ef4 commit d9cbe60
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/silly-rivers-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/myaccount": patch
---

Handle passwords containing special characters when updating password via my account.
15 changes: 10 additions & 5 deletions apps/myaccount/src/api/change-password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand All @@ -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,
Expand Down

0 comments on commit d9cbe60

Please sign in to comment.