requested changes & style cleanup

This commit is contained in:
Alexis Viguié 2020-05-08 13:19:05 +02:00
parent 3d9f99a883
commit acb23ef2bc
5 changed files with 13 additions and 13 deletions

View File

@ -21,14 +21,17 @@ class Api::V1::AccountsController < Api::BaseController
end
def create
not_found
# token = AppSignUpService.new.call(doorkeeper_token.application, account_params)
# response = Doorkeeper::OAuth::TokenResponse.new(token)
if ENV['HCAPTCHA_ENABLED'] == 'true'
not_found
else
token = AppSignUpService.new.call(doorkeeper_token.application, account_params)
response = Doorkeeper::OAuth::TokenResponse.new(token)
# headers.merge!(response.headers)
headers.merge!(response.headers)
# self.response_body = Oj.dump(response.body)
# self.status = response.status
self.response_body = Oj.dump(response.body)
self.status = response.status
end
end
def follow

View File

@ -96,10 +96,10 @@ class Auth::RegistrationsController < Devise::RegistrationsController
def check_captcha
if ENV['HCAPTCHA_ENABLED'] == 'true' && !verify_hcaptcha
self.resource = resource_class.new sign_up_params
build_resource(sign_up_params)
resource.validate
flash[:alert] = Hcaptcha::Helpers.to_error_message(:verification_failed)
respond_with_navigational(resource) { render :new }
resource.errors.add(:base, flash.delete(:hcaptcha_error))
respond_with resource
end
end

View File

@ -148,5 +148,4 @@ module ApplicationHelper
json = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(state_params), serializer: InitialStateSerializer).to_json
content_tag(:script, json_escape(json).html_safe, id: 'initial-state', type: 'application/json')
end
end

View File

@ -16,7 +16,7 @@ if Rails.env.production?
attachments_host = nil
end
hcaptcha_hosts = ["https://hcaptcha.com", "https://*.hcaptcha.com"]
hcaptcha_hosts = ENV['HCAPTCHA_ENABLED'] == 'true' ? ["https://hcaptcha.com", "https://*.hcaptcha.com"] : nil
data_hosts << attachments_host unless attachments_host.nil?

View File

@ -543,8 +543,6 @@ en:
deletion:
desc_html: Allow anyone to delete their account
title: Open account deletion
errors:
captcha_fail: Captcha verification failed
min_invite_role:
disabled: No one
title: Allow invitations by