mirror of
https://github.com/internetee/registry.git
synced 2025-06-05 20:27:30 +02:00
Merge remote-tracking branch 'origin/add-registrant-api-token-log' into add-role-filter-to-registrant-api
This commit is contained in:
commit
f60bf4013c
60 changed files with 1153 additions and 178 deletions
|
@ -11,7 +11,7 @@ module Api
|
|||
end
|
||||
|
||||
def authenticate_shared_key
|
||||
api_key = "Basic #{ENV['api_shared_key']}"
|
||||
api_key = "Basic #{ENV['rwhois_internal_api_shared_key']}"
|
||||
head(:unauthorized) unless api_key == request.authorization
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module Api
|
||||
module V1
|
||||
class BouncesController < BaseController
|
||||
before_action :authenticate_shared_key
|
||||
before_action :validate_shared_key_integrity
|
||||
|
||||
# POST api/v1/bounces/
|
||||
def create
|
||||
|
@ -20,6 +20,13 @@ module Api
|
|||
|
||||
params.require(:data)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def validate_shared_key_integrity
|
||||
api_key = "Basic #{ENV['rwhois_bounces_api_shared_key']}"
|
||||
head(:unauthorized) unless api_key == request.authorization
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
37
app/controllers/api/v1/contact_requests_controller.rb
Normal file
37
app/controllers/api/v1/contact_requests_controller.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
module Api
|
||||
module V1
|
||||
class ContactRequestsController < BaseController
|
||||
before_action :authenticate_shared_key
|
||||
|
||||
# POST api/v1/contact_requests/
|
||||
def create
|
||||
return head(:bad_request) if contact_request_params[:email].blank?
|
||||
|
||||
contact_request = ContactRequest.save_record(contact_request_params)
|
||||
render json: contact_request, status: :created
|
||||
rescue StandardError
|
||||
head(:bad_request)
|
||||
end
|
||||
|
||||
def update
|
||||
return head(:bad_request) if params[:id].blank?
|
||||
|
||||
process_id(params[:id])
|
||||
end
|
||||
|
||||
def process_id(id)
|
||||
record = ContactRequest.find_by(id: id)
|
||||
return :not_found unless record
|
||||
|
||||
record.update_status(contact_request_params)
|
||||
render json: record, status: :ok
|
||||
rescue StandardError
|
||||
head :bad_request
|
||||
end
|
||||
|
||||
def contact_request_params
|
||||
params.require(:contact_request).permit(:email, :whois_record_id, :name, :status, :ip)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -19,6 +19,8 @@ module Api
|
|||
token = create_token(user)
|
||||
|
||||
if token
|
||||
ToStdout.msg("Bearer for #{eid_params[:first_name]} #{eid_params[:last_name]} " \
|
||||
"(#{eid_params[:ident]}) - '#{token[:access_token]}'")
|
||||
render json: token
|
||||
else
|
||||
render json: { errors: [{ base: ['Cannot create generate session token'] }] }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue