bot challenge for signup
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user