Skip to content

Commit

Permalink
Added check for current team country
Browse files Browse the repository at this point in the history
  • Loading branch information
ok200paul committed Sep 30, 2024
1 parent 3120baf commit ef20346
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/Enums/ApiResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum ApiResponse: string
case RESPONSE_COUNTRY_MISMATCH = 'Country mismatch.';
case RESPONSE_INVALID_MERCHANT_TEAM = 'Invalid merchant team.';
case RESPONSE_INVALID_MERCHANT_TEAM_FOR_SERVICE_TEAM = 'Invalid merchant team for this service team. Ensure merchant team is merchant of service team.';
case RESPONSE_INVALID_TEAM = 'Invalid team.';
case RESPONSE_INVALID_VOUCHER_TEMPLATE_FOR_TEAM = 'Invalid voucher template for team.';
case RESPONSE_QUERY_FILTER_DISALLOWED = 'Query filter disallowed';
case RESPONSE_REDEMPTION_FAILED_VOUCHER_ALREADY_FULLY_REDEEMED = 'This voucher has already been fully redeemed, no redemption made this time.';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,18 @@ public function store(): JsonResponse

try {

/**
* Ensure the API user has a country against their current team.
*/
if(!isset(Auth::user()->currentTeam->country_id))
{
$this->message = ApiResponse::RESPONSE_INVALID_TEAM->value;
$this->responseCode = 400;

return $this->respond();
}


DB::beginTransaction();

$merchantTeamIds = $this->request->get('merchant_team_ids');
Expand Down Expand Up @@ -321,6 +333,7 @@ public function store(): JsonResponse

$model->created_by_user_id = Auth::id();
$model->created_by_team_id = Auth::user()->current_team_id;
$model->currency_country_id = Auth::user()->currentTeam?->country_id;
$model->save();

foreach ($merchantTeamIds as $merchantTeamId) {
Expand Down

0 comments on commit ef20346

Please sign in to comment.