bot challenge for signup

This commit is contained in:
2023-01-20 09:35:45 +02:00
parent 58696d2168
commit 82358d8642
9 changed files with 44 additions and 24 deletions

View File

@ -6,9 +6,15 @@ class RegistrationsController < Devise::RegistrationsController
prepend_before_action :authenticate_scope!, only: [:edit_email]
def new
build_resource
super
end
# POST /resource
def create
puts "CREATE"
if message = math_check
flash.now.alert = message
end
super
end
@ -28,16 +34,24 @@ class RegistrationsController < Devise::RegistrationsController
super
end
def resource_name
"member"
end
# DELETE /resource
# def destroy
# super
# end
# protected
protected
def math_check
return "no cheatin" unless bot = params[:bot]
return "No food" unless fudder = bot[:fudder]
key = fudder.to_i / 2
answer = bot[:challenge]
return "Plase enter the bot challenge" if answer.blank?
if( (2*key + 1).to_s != answer )
return "Check the maths, tip, it wasn't #{answer}"
end
nil
end
# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_up_params