Browse Source

Fix null group_id on twofaccount creation with specific default group

Bubka 3 năm trước cách đây
mục cha
commit
6533f844d9

+ 2 - 1
app/Api/v1/Controllers/TwoFAccountController.php

@@ -92,7 +92,7 @@ class TwoFAccountController extends Controller
         // Possible group association
         $this->groupService->assign($twofaccount->id);
 
-        return (new TwoFAccountReadResource($twofaccount))
+        return (new TwoFAccountReadResource($twofaccount->refresh()))
                 ->response()
                 ->setStatusCode(201);
     }
@@ -178,6 +178,7 @@ class TwoFAccountController extends Controller
             $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',

+ 1 - 1
app/Api/v1/Resources/TwoFAccountReadResource.php

@@ -15,7 +15,7 @@ class TwoFAccountReadResource extends TwoFAccountStoreResource
         return array_merge(
             [
                 'id'            => $this->id,
-                'group_id'      => $this->group_id,
+                'group_id'      => intval($this->group_id),
             ],
             parent::toArray($request)
         );