RitaGlushkova / immersive-go-course

Creative Commons Zero v1.0 Universal
0 stars 0 forks source link

Bug 5: After updating password user or potential attacker can still login with the old password #64

Open RitaGlushkova opened 2 years ago

RitaGlushkova commented 2 years ago

Describe the Bug

User changes their password but can still access their notes using both old and new passwords.

How to Reproduce

  1. Add a flag -update (boolean) to user sets of flags change the logic in the userCmd function to: if f.update == true -> update password of an existing user else -> create a new user

  2. Create a new user go run ./cmd/test user -password pear -id rita123 - creates a user rita123 with password 'pear'

  3. Create a note for this user go run ./cmd/test note -owner rita123 -content "This is my note about pear" - creates a note for user rita123 with content "This is my note about pear"

  4. Update the user's password go run ./cmd/test user -password orange -id rita123 -update - updates password to orange for user rita123

using Postman create a GET request to 127.0.0.1:8090/1/my/notes.json with basic authentication for the user rita123 and old password pear

Expected Behavior Expected to see an unauthorized response

Actual Behaviour

Receiving actual notes with old password pear

Screenshot 2022-11-30 at 18 44 03

Receiving actual notes with new password orange

Screenshot 2022-11-30 at 18 43 54