maxlemieux / quokka

Project 3 "Quokka"
MIT License
0 stars 2 forks source link

Add unique constraint to a field on Plants #50

Closed maxlemieux closed 4 years ago

maxlemieux commented 4 years ago

Plants favorites saved to mongo can be duplicated.

We need to add a unique constraint in the model file to prevent this.

Also a conditional display of 'Add Favorite' button if it is already a favorite.

maxlemieux commented 4 years ago

Unique constraint works great. We are still working on conditional display

maxlemieux commented 4 years ago

Unique constraint doesn't work so great on user_name when the user is 'guest'.

This is part of a bigger issue with tracking guest contributions. IP addresses from 'req.ip' are insufficient as a unique identifier since Heroku's internal networking changes IP addresses often.

We need to examine the request object for other sources of truth on the client IP address, perhaps x-forwarded-for?

maxlemieux commented 4 years ago

x-forwarded for works - also our interface doesn't allow for adding a favorite more than once due to conditional display of favorite button. Closing this issue.