Skip to content

Commit

Permalink
Switch to reCAPTCHA v2. Closes #114
Browse files Browse the repository at this point in the history
  • Loading branch information
odinsride committed Aug 18, 2020
1 parent 62ab342 commit a3ecd79
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased] changes

## [v1.7.2] - 2020-08-18

### New
- User registration now requires passing reCAPTCHA. This is to further prevent spam registrations.

## [v1.7.1] - 2020-08-17

### New
Expand Down Expand Up @@ -226,7 +231,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Account overview with list of all accounts and balances for each


[Unreleased]: https://github.com/odinsride/olubalance/compare/v1.7.1...develop
[Unreleased]: https://github.com/odinsride/olubalance/compare/v1.7.2...develop
[v1.7.1]: https://github.com/odinsride/olubalance/compare/v1.7.1...v1.7.2
[v1.7.1]: https://github.com/odinsride/olubalance/compare/v1.7.0...v1.7.1
[v1.7.0]: https://github.com/odinsride/olubalance/compare/v1.6.4...v1.7.0
[v1.6.4]: https://github.com/odinsride/olubalance/compare/v1.6.3...v1.6.4
Expand Down
21 changes: 5 additions & 16 deletions app/controllers/registrations_controller.rb
Expand Up @@ -6,22 +6,11 @@ class RegistrationsController < Devise::RegistrationsController
private

def check_captcha
success = verify_recaptcha(action: 'registration', minimum_score: 0.5)
checkbox_success = verify_recaptcha unless success
if success || checkbox_success

else
if !success
@show_checkbox_recaptcha = true
end
render 'new'
unless verify_recaptcha
self.resource = resource_class.new sign_up_params
resource.validate # Look for any other validation errors besides reCAPTCHA
set_minimum_password_length
respond_with_navigational(resource) { render :new }
end

# unless verify_recaptcha
# self.resource = resource_class.new sign_up_params
# resource.validate # Look for any other validation errors besides reCAPTCHA
# set_minimum_password_length
# respond_with_navigational(resource) { render :new }
# end
end
end
12 changes: 6 additions & 6 deletions app/views/devise/registrations/components/_formNew.html.erb
Expand Up @@ -115,12 +115,12 @@
</div>
</div>

<%= flash[:recaptcha_error] %>
<% if @show_checkbox_recaptcha %>
<%= recaptcha_tags %>
<% else %>
<%= recaptcha_v3(action: 'registration') %>
<% end %>
<div class="columns">
<div class="column">
<%= flash[:recaptcha_error] %>
<%= recaptcha_tags %>
</div>
</div>
</div>

</div> <!-- /columns -->
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Expand Up @@ -23,7 +23,7 @@ class Application < Rails::Application
config.load_defaults 6.0

# olubalance Version
config.version = "1.7.1"
config.version = "1.7.2"

# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
Expand Down

0 comments on commit a3ecd79

Please sign in to comment.