mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-14 07:48:37 +02:00
Better errors handling for TwoFAccount controller
This commit is contained in:
@ -24,7 +24,7 @@ class IconController extends Controller
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(['error' => $validator->errors()], 400);
|
||||
return response()->json(['validation' => $validator->errors()], 400);
|
||||
}
|
||||
|
||||
$path = $request->file('icon')->storePublicly('public/icons');
|
||||
|
@ -28,7 +28,7 @@ class QrCodecontroller extends Controller
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(['error' => $validator->errors()], 400);
|
||||
return response()->json(['validation' => $validator->errors()], 400);
|
||||
}
|
||||
|
||||
// qrcode analysis
|
||||
@ -65,7 +65,7 @@ class QrCodecontroller extends Controller
|
||||
catch (AssertionFailedException $exception) {
|
||||
|
||||
return response()->json([
|
||||
'error' => [
|
||||
'validation' => [
|
||||
'qrcode' => __('errors.response.no_valid_totp')
|
||||
]
|
||||
], 400);
|
||||
|
@ -40,7 +40,7 @@ class TwoFAccountController extends Controller
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json(['error' => $validator->errors()], 400);
|
||||
return response()->json(['validation' => $validator->errors()], 400);
|
||||
}
|
||||
|
||||
$twofaccount = TwoFAccount::create([
|
||||
@ -66,7 +66,7 @@ class TwoFAccountController extends Controller
|
||||
$twofaccount = TwoFAccount::FindOrFail($id);
|
||||
return response()->json($twofaccount, 200);
|
||||
} catch (\Exception $e) {
|
||||
return response()->json( ['error' => 'not found' ], 404);
|
||||
return response()->json( ['message' => 'not found' ], 404);
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ class TwoFAccountController extends Controller
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json( ['error' => $validator->errors() ], 400);
|
||||
return response()->json( ['validation' => $validator->errors() ], 400);
|
||||
}
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ class TwoFAccountController extends Controller
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
|
||||
return response()->json( ['error' => 'not found' ] , 404);
|
||||
return response()->json( ['message' => 'not found' ] , 404);
|
||||
|
||||
}
|
||||
}
|
||||
@ -146,7 +146,7 @@ class TwoFAccountController extends Controller
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
|
||||
return response()->json('already gone', 404);
|
||||
return response()->json(['message' => 'already gone'], 404);
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user