Skip to content

Commit 50adea1

Browse files
Merge pull request #1223 from TechnologyEnhancedLearning/Develop/Fixes/TD-5708-FileUpload-Password-issue
TD-5708: Password validation is failing for the users with password '&;
2 parents b0dace0 + 7af1e40 commit 50adea1

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

LearningHub.Nhs.WebUI/Controllers/Api/UserController.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ public async Task<ActionResult> CheckUserRole()
102102
/// <summary>
103103
/// to check user password is correct.
104104
/// </summary>
105-
/// <param name="currentPassword">The currentPassword.</param>
105+
/// <param name="password">The currentPassword.</param>
106106
/// <returns>The <see cref="Task{ActionResult}"/>.</returns>
107-
[HttpGet]
108-
[Route("ConfirmPassword/{currentPassword}")]
109-
public async Task<ActionResult> ConfirmPassword(string currentPassword)
107+
[HttpPost]
108+
[Route("ConfirmPassword")]
109+
public async Task<ActionResult> ConfirmPassword([FromBody] PasswordUpdateModel password)
110110
{
111-
string passwordHash = this.userService.Base64MD5HashDigest(currentPassword);
111+
string passwordHash = this.userService.Base64MD5HashDigest(password.PasswordHash);
112112
var userPersonalDetails = await this.userService.GetCurrentUserPersonalDetailsAsync();
113113
if (userPersonalDetails != null && userPersonalDetails.PasswordHash == passwordHash)
114114
{

LearningHub.Nhs.WebUI/Scripts/vuesrc/data/user.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,15 @@ const IsSystemAdmin = async function (): Promise<boolean[]> {
6767
};
6868

6969
const IsValidUser = async function (currentPassword: string): Promise<boolean[]> {
70-
let encodedPassword = encodeURIComponent(currentPassword);
71-
var IsValidUser = `/api/User/ConfirmPassword/${encodedPassword}`;
72-
return await AxiosWrapper.axios.get<boolean[]>(IsValidUser)
73-
.then(response => {
74-
return response.data;
75-
})
76-
.catch(e => {
77-
console.log('IsValidUser:' + e);
78-
throw e;
70+
try {
71+
const response = await AxiosWrapper.axios.post<boolean[]>('/api/User/ConfirmPassword', {
72+
PasswordHash: currentPassword
7973
});
74+
return response.data;
75+
} catch (e) {
76+
console.error('IsValidUser:', e);
77+
throw e;
78+
}
8079
};
8180

8281
const getCurrentUserBasicDetails = async function (): Promise<UserBasicModel> {

0 commit comments

Comments
 (0)