varunKT001 / tomper-wear-ecommerce

E-commerce web-application for selling clothing essentials 😀
https://tomper-wear.netlify.app
MIT License
38 stars 48 forks source link

Feature Request: Existing password needed while changing password #41

Closed Siddhesh777 closed 2 years ago

Siddhesh777 commented 2 years ago

Is your feature request related to a problem? Please describe.

I will never like that someone changes password of my account. In /profile route there is a provision for changing the password. To change the current password, user must enter the existing password, If it doesn't match then password should not change.

issue

Describe the solution you'd like.

We should take current password as input from user. if it matched ,let the user change the password, else he/she can't.

Additional context (if any)

I am contributor at gssoc'22. Please assign this task to me

github-actions[bot] commented 2 years ago

Hey @Siddhesh777 👋, thank you for raising an issue. Please make sure that it is detailed, and also following the provided template.

varunKT001 commented 2 years ago

@Siddhesh777 Good idea 🚀

But that will require some firebase stuff, and I hope you are comfortable with firebase.

If you need any help, ping me on the TomperWear discord channel 👍

Siddhesh777 commented 2 years ago

hey @varunKT001 😅 Just needed small help. I learned all the basic stuffs of firebase but I am unable to know how can we compare the the existing password of currentUser. Can you help me for this?😅

varunKT001 commented 2 years ago

@Siddhesh777 There is no specific method just to compare passwords. What you can do is to use reauthenticateWithCredential method provided by firebase. For this, you have to provide the user's email (which is already in the currentUser state) and the current password. If the authentication was successful, you can update the password, otherwise, you can show an error message 👍

Refer to firebase docs for more info: https://firebase.google.com/docs/auth/web/manage-users#re-authenticate_a_user

Siddhesh777 commented 2 years ago

Thank you very much @varunKT001

Siddhesh777 commented 2 years ago

hey @varunKT001 I am trying to solve this issue from long. But I am getting following error,Can you please guide me how can I correct it? 1 2

varunKT001 commented 2 years ago

@Siddhesh777 Before moving to the error:

Coming to the error:

const credentials = EmailAuthProvider.credentials(currentUser.email, existingPassword)

You don't have to use auth.EmailAuthProvider now . . .

Try it, and if the problem still persists, tag me here, I'll look into it 👍