Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use neverthrow in verification module #1440

Closed
wants to merge 28 commits into from

Conversation

mantariksh
Copy link
Contributor

@mantariksh mantariksh commented Mar 23, 2021

Not to be merged until #1443 goes into production.

Problem

  1. Most of the backend is written using neverthrow to chain asynchronous operations, but the verification module is not.
  2. The verification module handles errors by sending custom strings (e.g. 'SEND_OTP_FAILED', 'INVALID_OTP') to the frontend, which then uses a switch statement to determine the error message to render. This is an inflexible approach as any change in the error message cannot be propagated to existing clients.

Solution

  1. Rewrite the verification module using neverthrow. All existing functionality should be preserved.
  2. Send error messages from the backend and render them in the frontend (see verifiable-field.client.component.js for frontend changes).

Other improvements

Test suite has been enhanced with factory and integration tests.

Tests

Email OTP verification

  • Request for OTP and enter correct OTP. Field should be shown as verified.
  • Request for OTP and enter incorrect OTP 3 times, then enter correct OTP. Field should be shown as verified.
  • Request for OTP and enter incorrect OTP 4 times, then enter correct OTP. Field should NOT be able to be verified as max retry count has been exceeded.
  • Open network tab. Request for OTP, then within 30 seconds, replay the network request. You should get a 400 as the waiting time between OTP requests has not elapsed.
  • Request for OTP then wait for 10 minutes, then enter the OTP. OTP should not be verified as it has expired.

Mobile OTP verification

  • Request for OTP and enter correct OTP. Field should be shown as verified.
  • Request for OTP and enter incorrect OTP 3 times, then enter correct OTP. Field should be shown as verified.
  • Request for OTP and enter incorrect OTP 4 times, then enter correct OTP. Field should NOT be able to be verified as max retry count has been exceeded.
  • Open network tab. Request for OTP, then within 30 seconds, replay the network request. You should get a 400 as the waiting time between OTP requests has not elapsed.
  • Request for OTP then wait for 10 minutes, then enter the OTP. OTP should not be verified as it has expired.

@mantariksh
Copy link
Contributor Author

Note: not to be merged until #1443 goes into production

@mantariksh
Copy link
Contributor Author

Breaking this PR into smaller parts

@mantariksh mantariksh closed this Mar 24, 2021
@mantariksh mantariksh deleted the ref/vfn-neverthrow branch April 13, 2021 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant