Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Delete keys when revoked
Browse files Browse the repository at this point in the history
  • Loading branch information
insom committed Mar 22, 2016
1 parent 2493f40 commit a17be78
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/Http/Controllers/Dashboard/UserController.php
Expand Up @@ -13,6 +13,7 @@

use AltThree\Validator\ValidationException;
use CachetHQ\Cachet\Models\User;
use CachetHQ\Cachet\Models\ApiKey;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
Expand Down Expand Up @@ -71,10 +72,9 @@ public function postUser()
*
* @return \Illuminate\View\View
*/
public function regenerateApiKey(User $user)
public function revokeApiKey(User $user, ApiKey $api_key)
{
$user->api_key = User::generateApiKey();
$user->save();
$api_key->delete();

return Redirect::route('dashboard.user');
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Routes/DashboardRoutes.php
Expand Up @@ -220,7 +220,7 @@ public function map(Registrar $router)
'uses' => 'UserController@showUser',
]);
$router->post('/', 'UserController@postUser');
$router->get('{user}/api/regen', 'UserController@regenerateApiKey');
$router->get('{user}/api/revoke/{api_key}', 'UserController@revokeApiKey');
});

$router->group(['prefix' => 'api'], function (Registrar $router) {
Expand Down

0 comments on commit a17be78

Please sign in to comment.