Created
November 19, 2017 18:32
-
-
Save Tjoosten/30b6ad0a9b908a8587bffd8fdab064c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Delete an api key out off the storage. | |
* | |
* @param integer $keyId The unique identifier in the storage. | |
* @return \Illuminate\Http\RedirectResponse | |
*/ | |
public function delete($keyId): RedirectResponse | |
{ | |
$apiKey = $this->apiKeyRepository->find($keyId) ?: abort(Response::HTTP_NOT_FOUND); | |
if (Gate::allows('delete', $apiKey) && $apiKey->delete()) { | |
$this->usersRepository->find($apiKey->apikeyable_id)->notify(new ApiKeyDeleteNotification()); | |
flash("De API sleutel voor de service {$apiKey->service} is verwijderd.")->success(); | |
if (auth()->user()->hasRole('admin')) { | |
// TODO: Implement activity logger | |
} | |
} | |
return redirect()->to($this->apiKeyRepository->getRedirectRoute()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment