Bug 566 - Member reset password unsuccessfully
Summary: Member reset password unsuccessfully
Status: RESOLVED FIXED
Alias: None
Product: New-Territories-Cycle-Track-Navigation-System
Classification: Unclassified
Component: JsonOperation (show other bugs)
Version: 1.0
Hardware: PC Windows
: Normal normal
Assignee: lst
URL:
Depends on:
Blocks:
 
Reported: 2021-11-16 11:22 HKT by lst
Modified: 2021-11-16 11:41 HKT (History)
0 users

See Also:


Attachments
Login successfully before resetting password (21.16 KB, image/png)
2021-11-16 11:22 HKT, lst
Details
New passsword login unsuccessfully (9.31 KB, image/png)
2021-11-16 11:23 HKT, lst
Details

Note You need to log in before you can comment on or make changes to this bug.
Description lst 2021-11-16 11:22:48 HKT
Created attachment 83 [details]
Login successfully before resetting password
Comment 1 lst 2021-11-16 11:23:27 HKT
Created attachment 84 [details]
New passsword login unsuccessfully
Comment 2 lst 2021-11-16 11:31:06 HKT
Steps to reproduce:

Step 1: Log in to the system with the original password "pwd".
Step 2: Reset the password as "newPwd".
Step 3: End the program.
Step 4: Re-login to the system with the new password "newPwd", unsuccessfully.
Step 5: Re-login to the system with the original password "pwd", successfully.

Actual result: the new password is invalid.
Expected result: the new password should be valid to log in to the system.
Comment 3 lst 2021-11-16 11:41:14 HKT
Reason:
JsonOperation.resetPwd: 
        JSONObject memberInfo = getMemberInfo(email);
        memberInfo.replace("password", pwd);
Here we changed the JSONObject, but the JSON file has not been midified. We need to write in and update the JSON file.

Solution: 
JsonOperation.updateJsonFile:
        File memberListFile = new File("docs\\MemberInfo.json");
        FileOutputStream fos = new FileOutputStream(memberListFile, true);
        OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
        JsonOperation.clearJsonFile();
        osw.write(getWholeObjectString());
        osw.close();
We add this updateJsonFile method at the end of the resetPwd method. The the problem is resolved.

Furthermore, we add this updateJsonFile component at every method which will focus on changing the content of JSO files (JsonOperation.deleteMemberBookmark, JsonOperation.addNewMember, JsonOperation.addNewSchedule, etc.)