From 6533f844d9eff50fae5b7795897c14f3e5d45c06 Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Tue, 16 Nov 2021 23:45:30 +0100 Subject: [PATCH] Fix null group_id on twofaccount creation with specific default group --- app/Api/v1/Controllers/TwoFAccountController.php | 3 ++- app/Api/v1/Resources/TwoFAccountReadResource.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Api/v1/Controllers/TwoFAccountController.php b/app/Api/v1/Controllers/TwoFAccountController.php index 38660f50..266910e7 100644 --- a/app/Api/v1/Controllers/TwoFAccountController.php +++ b/app/Api/v1/Controllers/TwoFAccountController.php @@ -92,7 +92,7 @@ public function store(TwoFAccountDynamicRequest $request) // Possible group association $this->groupService->assign($twofaccount->id); - return (new TwoFAccountReadResource($twofaccount)) + return (new TwoFAccountReadResource($twofaccount->refresh())) ->response() ->setStatusCode(201); } @@ -178,6 +178,7 @@ public function otp(Request $request, $id = null) $otp = $this->twofaccountService->getOTP($validatedData['uri']); } + // return bad request if uri is provided with any other input else if ( count($inputs) > 1 && $request->has('uri')) { return response()->json([ 'message' => 'bad request', diff --git a/app/Api/v1/Resources/TwoFAccountReadResource.php b/app/Api/v1/Resources/TwoFAccountReadResource.php index 82d32ec9..4ad177f7 100644 --- a/app/Api/v1/Resources/TwoFAccountReadResource.php +++ b/app/Api/v1/Resources/TwoFAccountReadResource.php @@ -15,7 +15,7 @@ public function toArray($request) return array_merge( [ 'id' => $this->id, - 'group_id' => $this->group_id, + 'group_id' => intval($this->group_id), ], parent::toArray($request) );