poanetwork / poa-popa

DApp for proof of physical address (PoPA) attestation for validators of POA Network
https://popa.poa.network
GNU General Public License v3.0
24 stars 18 forks source link

(Feature) Limit number of postcards sent per day #120

Closed fvictorio closed 6 years ago

fvictorio commented 6 years ago

Closes #115.

This limits the number of postcards send in a given day to 10 (configurable). The counter is increased after the postcard was sent. When the limit is reached, no further registrations can be done.

coveralls commented 6 years ago

Pull Request Test Coverage Report for Build 378


Changes Missing Coverage Covered Lines Changed/Added Lines %
web-dapp/src/components/RegisterAddressPage.js 3 4 75.0%
web-dapp/server-lib/postcard_limiter.js 12 14 85.71%
web-dapp/routes/prepare_reg_tx.js 5 7 71.43%
web-dapp/server-lib/session-stores/redis.js 6 8 75.0%
web-dapp/server-lib/session-stores/memory.js 2 5 40.0%
web-dapp/controllers/notifyRegTx.js 2 13 15.38%
<!-- Total: 36 57 63.16% -->
Files with Coverage Reduction New Missed Lines %
web-dapp/server-lib/post_api.js 1 50.0%
web-dapp/server-lib/session-stores/memory.js 4 57.14%
web-dapp/server-lib/session-stores/redis.js 8 60.42%
web-dapp/src/components/MyAddressesPage.js 9 77.78%
web-dapp/src/components/ConfirmationPage.js 14 77.5%
<!-- Total: 36 -->
Totals Coverage Status
Change from base Build 370: -1.5%
Covered Lines: 893
Relevant Lines: 1175

💛 - Coveralls
phahulin commented 6 years ago

@fvictorio LGTM, except the error message that is displayed on the front-end when limit is reached. Right now it's general "Server error, bad request". I think this line can be changed https://github.com/poanetwork/poa-popa/blob/master/web-dapp/server-lib/send_response.js#L9 to always return 200, then error message will be displayed properly.

fvictorio commented 6 years ago

@phahulin Fixed. Returning a 200 wouldn't work because the promise chain needs to be interrupted, but I slightly modified the code that handles error messages in the front so that the error shows up.