This repository has been archived by the owner on Jan 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix more bugs found during testing on staging (#286)
* correctly import the polling * unhardcode the routes * at v2 to competitions * add cors headers to lambda * correctly add attendee_id to polling url * remove unnecessary eslint comment * fix event_change_deadline being null breaking the validate events check * corrected the headers in lambda * Correctly assemble attendee_id for polling * correctly return competing_status wrapped in { competing } * correctly read competition info from the right WCA_HOST * add null guard to data * remove payment_init path as it is local * correctly find competition in payment_init * check if registration is nil when trying to generate a payment ticket * use EnvConfig when accessing WCA_HOST * add https to url * add missing JSON.stringify * correctly name paymentId to id * update correct name for payment_id * send the data in a ruby_snake_case * correctly set user * put attendee_id as get parameter * create update_payment_status route * return payment_status on the frontend * run rubocop * add WCA_HOST to dev and test * handle payment being done * correctly return payment_status
- Loading branch information
1 parent
374ff3c
commit 61f9715
Showing
22 changed files
with
190 additions
and
53 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
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
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,17 +1,17 @@ | ||
import backendFetch from '../../helper/backend_fetch' | ||
import { paymentIdRoute } from '../../helper/routes' | ||
|
||
export interface PaymentInfo { | ||
// This is the MySQL payment id that can be give to the payment service | ||
// to get the relevant data, not the Stripe ID! | ||
payment_id: string | ||
id: string | ||
status: string | ||
} | ||
// We get the user_id out of the JWT key, which is why we only send the | ||
// competition_id | ||
export default async function getPaymentId( | ||
competitionId: string | ||
): Promise<PaymentInfo> { | ||
return backendFetch(paymentIdRoute(competitionId), 'GET', { | ||
return backendFetch(`/${competitionId}/payment`, 'GET', { | ||
needsAuthentication: true, | ||
}) as Promise<PaymentInfo> | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'time' | ||
|
||
class InternalController < ApplicationController | ||
prepend_before_action :validate_token | ||
|
||
def validate_token | ||
service_token = request.headers['X-WCA-Service-Token'] | ||
unless service_token.present? | ||
return render json: { error: 'Missing Authentication' }, status: :forbidden | ||
end | ||
# The Vault CLI can't parse the response from identity/oidc/introspect so | ||
# we need to request it instead see https://github.com/hashicorp/vault/issues/9080 | ||
|
||
vault_token_data = Vault.auth_token.lookup_self.data | ||
# Renew our token if it has expired or is close to expiring | ||
if vault_token_data[:ttl] < 300 | ||
Vault.auth_token.renew_self | ||
end | ||
|
||
# Make the POST request to the introspect endpoint | ||
response = HTTParty.post("#{EnvConfig.VAULT_ADDR}/v1/identity/oidc/introspect", | ||
body: { token: service_token }.to_json, | ||
headers: { 'X-Vault-Token' => vault_token_data[:id], | ||
'Content-Type' => 'application/json' }) | ||
if response.ok? | ||
unless response['active'] | ||
render json: { error: 'Authentication Expired or Token Invalid' }, status: :forbidden | ||
end | ||
else | ||
raise "Introspection failed with the following error: #{response.status}, #{response.body}" | ||
end | ||
end | ||
|
||
def update_payment_status | ||
attendee_id = params.require(:attendee_id) | ||
payment_id = params.require(:payment_id) | ||
iso_amount = params.require(:iso_amount) | ||
currency_iso = params.require(:currency_iso) | ||
payment_status = params.require(:payment_status) | ||
registration = Registration.find(attendee_id) | ||
registration.update_payment_lane(payment_id, iso_amount, currency_iso, payment_status) | ||
render json: { 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
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
Oops, something went wrong.