2023-01-20 07:15:33 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class RegistrationsController < Devise::RegistrationsController
|
|
|
|
# before_action :configure_sign_up_params, only: [:create]
|
|
|
|
# before_action :configure_account_update_params, only: [:update]
|
|
|
|
prepend_before_action :authenticate_scope!, only: [:edit_email]
|
|
|
|
|
|
|
|
|
2023-01-20 08:35:45 +01:00
|
|
|
def new
|
|
|
|
build_resource
|
|
|
|
super
|
|
|
|
end
|
2023-01-20 07:15:33 +01:00
|
|
|
# POST /resource
|
|
|
|
def create
|
2023-01-20 08:35:45 +01:00
|
|
|
if message = math_check
|
|
|
|
flash.now.alert = message
|
|
|
|
end
|
2023-01-20 07:15:33 +01:00
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET /resource/edit
|
|
|
|
def edit_email
|
|
|
|
build_resource
|
|
|
|
puts "EDIT"
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
build_resource
|
|
|
|
super
|
|
|
|
end
|
|
|
|
# PUT /resource
|
|
|
|
def update
|
|
|
|
puts "UPDATE"
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
# DELETE /resource
|
|
|
|
# def destroy
|
|
|
|
# super
|
|
|
|
# end
|
|
|
|
|
2023-01-20 08:35:45 +01:00
|
|
|
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
|
2023-01-20 07:15:33 +01:00
|
|
|
|
|
|
|
# If you have extra params to permit, append them to the sanitizer.
|
|
|
|
# def configure_sign_up_params
|
|
|
|
# devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
|
|
|
|
# end
|
|
|
|
|
|
|
|
# If you have extra params to permit, append them to the sanitizer.
|
|
|
|
# def configure_account_update_params
|
|
|
|
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
|
|
|
|
# end
|
|
|
|
|
|
|
|
# The path used after sign up.
|
|
|
|
def after_sign_up_path_for(resource)
|
|
|
|
puts "after sign up"
|
|
|
|
super(resource)
|
|
|
|
end
|
|
|
|
|
|
|
|
# The path used after sign up for inactive accounts.
|
|
|
|
# def after_inactive_sign_up_path_for(resource)
|
|
|
|
# super(resource)
|
|
|
|
# end
|
|
|
|
end
|