Passwords can now be changed (#687)#694
Conversation
Nope this doesn't happen I believe. @ehuggett , you can also see the gif and over there too the password was being set the first time and no error shows. Errors show up only when we try to reset the password. The reset procedure fails once with status 401 and then proceeds with status 200 |
I get the error when using Firefox Developer Edition 58.0b13 (64-bit) & Firefox ESR 52.5.2 (64-bit) note: the 'reset' button is not well formatted in Firefox either
I see that now. sendPassword was only updating the stored nonce if the request failed, my changes to have it always update the file nonce seem clean enough so I've opened a PR to have you include them in your branch himanish-star#1 (which should cause it to be included here, so you should test it yourself before merging it). |
|
@ehuggett , thanks for the help. This issue has really helped me get a deeper understanding of the mozilla/send code base. So I need to correct the logic of existingPassword, got to format the reset Button and got to merge your branch onto mine. Ok I'm working on it. I'll make these changes later on , as I now got to go to college. If there are any other changes you want me to incorporate please do tell me. |
|
@shikhar-scs @himanish-star I appreciate your enthusiasm, but please chill 😉 I will be able to review your PRs soon. I'm the only current maintainer who can merge them. |
|
@dannycoates, sorry for the inconvenience 😅 |
|
@dannycoates, yeah Sorry for the inconvenience . |
9b26f2e to
6173e76
Compare
|
@ehuggett , Now you can have a look at the changes . I have fixed all the bugs and have made the requested changes and I have also merged your branch into my branch |
|
@dannycoates , shall I resolve the conflicts ? |
|
@himanish-star yes, you can resolve conflicts, but it will probably be a little while longer before this feature gets reviewed / merged. |
|
@dannycoates , ok I will do this in a later part of the day |
1daaf82 to
abc930c
Compare
|
@dannycoates , I have fixed the conflicts and things are back to normal. Here is a GIF with the changes |
dannycoates
left a comment
There was a problem hiding this comment.
This looks really good @himanish-star! Thanks for your patience. We might want to make a few little tweaks before pushing to production, but this is almost ready to merge.
app/fileSender.js
Outdated
| await sendPassword(file, oldAuthKey, rawAuth); | ||
| } else { | ||
| await sendPassword(file, authKey, rawAuth); | ||
| } |
There was a problem hiding this comment.
Just a nit on style... I'd prefer something like:
const aKey = existingPassword ? oldAuthKey : authKey;
await sendPassword(file, aKey, rawAuth);
app/templates/share.js
Outdated
|
|
||
| function toggleResetInput(event) { | ||
| const form = event.target.parentElement.querySelector('form'); | ||
| if (form.style.visibility === 'hidden' || form.style.visibility === '') |
There was a problem hiding this comment.
Another style nit: no ifs without brackets
app/fileSender.js
Outdated
| const xhr = new XMLHttpRequest(); | ||
| xhr.onreadystatechange = () => { | ||
| if (xhr.readyState === XMLHttpRequest.DONE) { | ||
| const nonce = xhr.getResponseHeader('WWW-Authenticate').split(' ')[1]; |
There was a problem hiding this comment.
There are cases where this header is not set (status == 404 for example), so would throw an exception here
| function resetPassword(event) { | ||
| event.preventDefault(); | ||
| const existingPassword = document.querySelector('.passwordOriginal') | ||
| .innerText; |
There was a problem hiding this comment.
This is regarding indentation . Shall I do this
const existingPassword = document.querySelector('.passwordOriginal')
.innerText;or this
const existingPassword = document.querySelector('.passwordOriginal').innerText;There was a problem hiding this comment.
In general try to keep it on one line, but our auto-formatter prettier might change it.
| if (xhr.status === 200) { | ||
| return resolve(xhr.response); | ||
| } | ||
| if (xhr.status === 401) { |
There was a problem hiding this comment.
Do you want me to revert this removed code back. If in case the status=401 then the below code would help to reset the file.nonce
if (xhr.status === 401) {
const nonce = xhr.getResponseHeader('WWW-Authenticate').split(' ')[1];
file.nonce = nonce;
}abc930c to
ef28050
Compare
app/templates/share.js
Outdated
| password: '<pre></pre>' | ||
| })}</div>` | ||
| })} | ||
| <button id="resetButton">Reset</button> |
There was a problem hiding this comment.
I missed this earlier... The "Reset" text here needs to be localized. We need to add a string to public/locales/en-US/send.ftl and use state.translate like the other strings here. I also think "Change" is a better word than "Reset" in this case.
There was a problem hiding this comment.
Yes , I know that it has to be localised. But I thought I would have to do it in a number of different languages . Thus I had left it alone. I'll make the changes soon.
| placeholder="${state.translate('unlockInputPlaceholder')}"> | ||
| <input type="submit" | ||
| id="unlock-reset-btn" | ||
| class="btn btn-hidden" |
There was a problem hiding this comment.
Does it work if you set onclick=${toggleResetInput} here instead of with the querySelector below? If so it's the preferred style. (also same with others)
There was a problem hiding this comment.
Yes, I know that this is the preferred style, but I had tried to do it this way but it hadn't worked. I'll try again and if it doesn't work , I'll ask you for help 😃
There was a problem hiding this comment.
Nope , using onclick=${toggleResetInput} doesn't work 😞. Can you try the same thing out once @dannycoates and I have also made the changes requested
There was a problem hiding this comment.
Thanks for checking @himanish-star. I see the reason it doesn't work... using the function form "html()" processes the string differently than the template string form "html``". We need to use the function form here so that the password text gets escaped properly. It's not a big deal.
There was a problem hiding this comment.
We need to use the function form here so that the password text gets escaped properly. It's not a big deal.
So you mean we can still write onclick=${toggleResetInput}. Ok, I'll try searching more over the net of how to do this. Meanwhile if you can suggest me of how this is done, then I will surely rectify my mistake
There was a problem hiding this comment.
No, no, I was just commenting on why we needed to use html() instead of html``
Your code is fine :)
ef28050 to
fdcc31f
Compare
|
Nice work @himanish-star! 💯 |
|
@dannycoates , Thank for merging. Can I take up issue #324 ? 😃 |

fixes: #687
@ehuggett , Thanks for the help I have added the ability to change password.
However I still face one error and that is as follows
The password does get reset but it fails once with status 401 and then proceeds as per the existing code below. It doesn't affect in any way(as you can see in the gif below that all works well) but still I would like to get rid of this error. Could you suggest how ? At the mean time I am also having a look into this matter