-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 3-dh-send_orders_to_api
- Loading branch information
Showing
12 changed files
with
333 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
RECAPTCHA_SITE_KEY= | ||
RECAPTCHA_SECRET_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
# require 'net/http' | ||
# Controller for google captcha | ||
class CaptchaController < ApplicationController | ||
skip_before_action :verify_authenticity_token | ||
|
||
# class CaptchaController < ApplicationController | ||
# def verify | ||
# Rails.logger.info("Received captcha verification request with token: #{params[:token]}") | ||
# Verifies Google reCAPTCHA token | ||
# | ||
# @param [String] captcha_token Token received from Google reCAPTCHA widget | ||
# | ||
# @return [JSON] Returns success status or error message | ||
# | ||
# @example verify(captcha_token: "03AGdBq24PBgMsJ-...") | ||
# | ||
# @example_return | ||
# { success: true } | ||
# { error: 'Invalid captcha' } | ||
def verify | ||
unless verify_recaptcha(response: params[:captcha_token]) | ||
render json: { error: 'Invalid captcha' }, status: :unprocessable_entity | ||
return | ||
end | ||
|
||
# token = params[:token] | ||
# secret_key = '6LdAFqMqAAAAAMm1WqbP92_q_Ef-xxO6md7dK-TW' | ||
|
||
# uri = URI('https://www.google.com/recaptcha/api/siteverify') | ||
# response = Net::HTTP.post_form(uri, { | ||
# 'secret' => secret_key, | ||
# 'response' => token | ||
# }) | ||
|
||
# result = JSON.parse(response.body) | ||
|
||
# if result['success'] | ||
# render json: { success: true } | ||
# else | ||
# render json: { success: false, errors: result['error-codes'] } | ||
# end | ||
# end | ||
# end | ||
render json: { success: true }, status: :ok | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This initializer configures Google reCAPTCHA integration for the application | ||
# It sets up the necessary API keys required for reCAPTCHA functionality | ||
# The keys are stored in environment variables for security: | ||
# - RECAPTCHA_SITE_KEY: Public key used in frontend | ||
# - RECAPTCHA_SECRET_KEY: Private key used for server-side verification | ||
Recaptcha.configure do |config| | ||
config.site_key = ENV['RECAPTCHA_SITE_KEY'] | ||
config.secret_key = ENV['RECAPTCHA_SECRET_KEY'] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.