Skip to content

ByeBot-Integrations/Ruby-on-Rails

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Byebot - Rails Example

A Ruby on Rails application demonstrating Byebot integration.

Installation

cd integrations/rails
bundle install

Configuration

Edit the constants in app/controllers/sessions_controller.rb and app/services/byebot_validator.rb:

BYEBOT_API_KEY = "your-api-key"
BYEBOT_SITE_KEY = "your-site-key"

Usage

bundle exec rails server -p 4242

Visit http://localhost:4242

How It Works

  1. Frontend: The widget is loaded via <script src="https://challenge.byebot.de/ray/widget.js">. A div with class="captcha-widget" and data-sitekey attribute renders the CAPTCHA.

  2. Token Submission: On verification, the widget adds a hidden byebot-token field to the form.

  3. Server Validation: POST the token to /validate_token:

uri = URI.parse("https://challenge.byebot.de/validate_token")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path)
request["Content-Type"] = "application/json"
request.body = { api_key: BYEBOT_API_KEY, token: token }.to_json
response = http.request(request)
# 200 OK = valid token

Files

  • app/controllers/sessions_controller.rb - Login form controller
  • app/services/byebot_validator.rb - Token validation service
  • app/views/sessions/new.html.erb - Login form with CAPTCHA widget
  • app/views/sessions/create.html.erb - Success page

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors