Fixes for routes"

git push
This commit is contained in:
David Bomba 2020-07-28 23:24:01 +10:00
parent 674f8b0f5b
commit fd97aff3f1
7 changed files with 16 additions and 16 deletions

View File

@ -51,7 +51,7 @@ class ClientController extends BaseController
public function show(Request $request, string $contact_key)
{
$company = Company::where('company_key', $request->header('X-API-COMPANY_KEY'))->first();
$company = Company::where('company_key', $request->header('X-API-COMPANY-KEY'))->first();
if(!$company->enable_shop_api)
return response()->json(['message' => 'Shop is disabled', 'errors' => []],403);
@ -66,7 +66,7 @@ class ClientController extends BaseController
public function store(StoreClientRequest $request)
{
$company = Company::where('company_key', $request->header('X-API-COMPANY_KEY'))->first();
$company = Company::where('company_key', $request->header('X-API-COMPANY-KEY'))->first();
if(!$company->enable_shop_api)
return response()->json(['message' => 'Shop is disabled', 'errors' => []],403);

View File

@ -52,7 +52,7 @@ class InvoiceController extends BaseController
public function show(string $invitation_key)
{
$company = Company::where('company_key', $request->header('X-API-COMPANY_KEY'))->first();
$company = Company::where('company_key', $request->header('X-API-COMPANY-KEY'))->first();
if(!$company->enable_shop_api)
return response()->json(['message' => 'Shop is disabled', 'errors' => []],403);
@ -69,7 +69,7 @@ class InvoiceController extends BaseController
public function store(StoreInvoiceRequest $request)
{
$company = Company::where('company_key', $request->header('X-API-COMPANY_KEY'))->first();
$company = Company::where('company_key', $request->header('X-API-COMPANY-KEY'))->first();
if(!$company->enable_shop_api)
return response()->json(['message' => 'Shop is disabled', 'errors' => []],403);

View File

@ -34,7 +34,7 @@ class ProductController extends BaseController
*/
public function index(Request $request)
{
$company = Company::where('company_key', $request->header('X-API-COMPANY_KEY'))->first();
$company = Company::where('company_key', $request->header('X-API-COMPANY-KEY'))->first();
if(!$company->enable_shop_api)
return response()->json(['message' => 'Shop is disabled', 'errors' => []],403);
@ -46,7 +46,7 @@ class ProductController extends BaseController
public function show(Request $request, string $product_key)
{
$company = Company::where('company_key', $request->header('X-API-COMPANY_KEY'))->first();
$company = Company::where('company_key', $request->header('X-API-COMPANY-KEY'))->first();
if(!$company->enable_shop_api)
return response()->json(['message' => 'Shop is disabled', 'errors' => []],403);

View File

@ -16,7 +16,7 @@ class Cors
// ALLOW OPTIONS METHOD
$headers = [
'Access-Control-Allow-Methods'=> 'POST, GET, OPTIONS, PUT, DELETE',
'Access-Control-Allow-Headers'=> 'X-API-COMPANY_KEY,X-API-SECRET,X-API-TOKEN,X-API-PASSWORD,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'
'Access-Control-Allow-Headers'=> 'X-API-COMPANY-KEY,X-API-SECRET,X-API-TOKEN,X-API-PASSWORD,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range'
];
return Response::make('OK', 200, $headers);
@ -36,7 +36,7 @@ class Cors
$response->headers->set('Access-Control-Allow-Origin', '*');
$response->headers->set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
$response->headers->set('Access-Control-Allow-Headers', 'X-API-COMPANY_KEY,X-API-SECRET,X-API-TOKEN,X-API-PASSWORD,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range');
$response->headers->set('Access-Control-Allow-Headers', 'X-API-COMPANY-KEY,X-API-SECRET,X-API-TOKEN,X-API-PASSWORD,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range');
$response->headers->set('Access-Control-Expose-Headers', 'X-APP-VERSION,X-MINIMUM-CLIENT-VERSION');
$response->headers->set('X-APP-VERSION', config('ninja.app_version'));
$response->headers->set('X-MINIMUM-CLIENT-VERSION', config('ninja.minimum_client_version'));

View File

@ -33,8 +33,8 @@ class SetDbByCompanyKey
];
if ($request->header('X-API-COMPANY_KEY') && config('ninja.db.multi_db_enabled')) {
if (! MultiDB::findAndSetDbByCompanyKey($request->header('X-API-COMPANY_KEY'))) {
if ($request->header('X-API-COMPANY-KEY') && config('ninja.db.multi_db_enabled')) {
if (! MultiDB::findAndSetDbByCompanyKey($request->header('X-API-COMPANY-KEY'))) {
return response()->json($error, 403);
}
} elseif (!config('ninja.db.multi_db_enabled')) {

View File

@ -5,8 +5,8 @@ use Illuminate\Support\Facades\Route;
Route::group(['middleware' => ['company_key_db','locale'], 'prefix' => 'api/v1'], function () {
Route::get('shop/products', 'Shop\ProductController@index');
Route::get('shop/clients', 'Shop\ClientController@index');
Route::get('shop/invoices', 'Shop\InvoiceController@index');
Route::post('shop/clients', 'Shop\ClientController@store');
Route::post('shop/invoices', 'Shop\InvoiceController@store');
Route::get('shop/client/{contact_key}', 'Shop\ClientController@show');
Route::get('shop/invoice/{invitation_key}', 'Shop\InvoiceController@show');
Route::get('shop/product/{product_key}', 'Shop\ProductController@show');

View File

@ -42,7 +42,7 @@ class ShopInvoiceTest extends TestCase
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-COMPANY_KEY' => $this->company->company_key
'X-API-COMPANY-KEY' => $this->company->company_key
])->get('/api/v1/shop/products');
@ -54,7 +54,7 @@ class ShopInvoiceTest extends TestCase
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-COMPANY_KEY' => $this->company->company_key
'X-API-COMPANY-KEY' => $this->company->company_key
])->get('/api/v1/products');
@ -72,7 +72,7 @@ class ShopInvoiceTest extends TestCase
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-COMPANY_KEY' => $this->company->company_key
'X-API-COMPANY-KEY' => $this->company->company_key
])->get('/api/v1/shop/product/'.$product->product_key);
@ -88,7 +88,7 @@ class ShopInvoiceTest extends TestCase
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-COMPANY_KEY' => $this->company->company_key
'X-API-COMPANY-KEY' => $this->company->company_key
])->get('/api/v1/shop/client/'.$this->client->contacts->first()->contact_key);