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: convert Captcha to service #827

Merged
merged 21 commits into from
Dec 9, 2020
Merged

refactor: convert Captcha to service #827

merged 21 commits into from
Dec 9, 2020

Conversation

mantariksh
Copy link
Contributor

@mantariksh mantariksh commented Dec 9, 2020

Problem

While captcha.factory.ts has been converted to TypeScript, it still exports middleware, which forces downstream functions to interact with captcha functionality through middleware.

Solution

This PR refactors captcha functionality into services exported through the captcha factory. The factory is a little strange because it has to export both Express middleware (for Joi validation) and a service function (for verifying the captcha response), but I felt this was the best way to implement proper layering.

Tests

  • Submit a form with captcha
  • Submit a form without captcha
  • Submit a form on staging-alt

@mantariksh mantariksh requested review from karrui and tshuli December 9, 2020 06:22
Copy link
Contributor

@karrui karrui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

src/app/services/captcha/captcha.errors.ts Show resolved Hide resolved
src/app/services/captcha/captcha.factory.ts Show resolved Hide resolved
src/app/services/captcha/captcha.factory.ts Outdated Show resolved Hide resolved
src/app/services/captcha/captcha.factory.ts Outdated Show resolved Hide resolved
@mantariksh mantariksh requested a review from karrui December 9, 2020 08:26
@mantariksh
Copy link
Contributor Author

@karrui requesting another review after converting class to HOF!

Copy link
Contributor

@karrui karrui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

src/app/services/captcha/captcha.factory.ts Outdated Show resolved Hide resolved
@mantariksh mantariksh merged commit 93bb779 into develop Dec 9, 2020
@mantariksh mantariksh mentioned this pull request Dec 10, 2020
@liangyuanruo liangyuanruo deleted the ref/ts-captcha branch January 26, 2021 13:53
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.

2 participants