Skip to content

Commit

Permalink
Merge branch 'crash13override-apiroutes'
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot committed May 2, 2016
2 parents 5367e65 + 6ec2eb0 commit 055c122
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
1 change: 0 additions & 1 deletion src/Mpociot/CaptainHook/Http/WebhookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class WebhookController extends Controller
*/
public function __construct()
{
$this->middleware('auth');
}

/**
Expand Down
44 changes: 29 additions & 15 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,34 @@
],

/*
|--------------------------------------------------------------------------
| Tenant configuration (Spark specific configuration)
|--------------------------------------------------------------------------
|
| The tenant model option allows you to associate the tenant_id
| to the Spark Team instead of the User like by default.
|
| Possible options are: 'User' or 'Team'
|
| If you use 'User' you should add the following to the 'filter' function:
| return $webhook->tenant_id == auth()->user()->getKey();
|
| If you use 'Team' you should add the following to the 'filter' function:
| return $webhook->tenant_id == auth()->user()->currentTeam->id;
*/
|--------------------------------------------------------------------------
| Tenant configuration (Spark specific configuration)
|--------------------------------------------------------------------------
|
| The tenant model option allows you to associate the tenant_id
| to the Spark Team instead of the User like by default.
|
| Possible options are: 'User' or 'Team'
|
| If you use 'User' you should add the following to the 'filter' function:
| return $webhook->tenant_id == auth()->user()->getKey();
|
| If you use 'Team' you should add the following to the 'filter' function:
| return $webhook->tenant_id == auth()->user()->currentTeam->id;
*/
'tenant_spark_model' => 'Team',

/*
|--------------------------------------------------------------------------
| API configuration (Spark specific configuration)
|--------------------------------------------------------------------------
|
| By enabling this option some extra routes will be added under
| the /api prefix and with the 'auth:api' middleware, to allow users and
| services like Zapier to create, update and delete Webhooks without user
| interaction.
| See more at http://resthooks.org/
|
*/
'uses_api' => true,
];
11 changes: 10 additions & 1 deletion src/routes.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<?php

Route::group(['middleware' => 'web'], function ($router) {
Route::group(['middleware' => ['auth', 'web']], function ($router) {
$router->get('/settings/api/webhooks', 'Mpociot\CaptainHook\Http\WebhookController@all');
$router->post('/settings/api/webhook', 'Mpociot\CaptainHook\Http\WebhookController@store');
$router->put('/settings/api/webhook/{webhook_id}', 'Mpociot\CaptainHook\Http\WebhookController@update');
$router->delete('/settings/api/webhook/{webhook_id}', 'Mpociot\CaptainHook\Http\WebhookController@destroy');

$router->get('/settings/api/webhooks/events', 'Mpociot\CaptainHook\Http\WebhookEventsController@all');
});

if (config('captain_hook.uses_api', false)) {
Route::group(['middleware' => 'auth:api', 'prefix' => 'api'], function ($router) {
$router->get('webhooks', 'Mpociot\CaptainHook\Http\WebhookController@all');
$router->post('webhook', 'Mpociot\CaptainHook\Http\WebhookController@store');
$router->put('webhook/{webhook_id}', 'Mpociot\CaptainHook\Http\WebhookController@update');
$router->delete('webhook/{webhook_id}', 'Mpociot\CaptainHook\Http\WebhookController@destroy');
});
}

0 comments on commit 055c122

Please sign in to comment.