Use a post request to delete SSH keys, some hashes use slashes which cause 404 errors; closes #4100
This commit is contained in:
parent
5143faa4b1
commit
03a497fb8a
5 changed files with 24 additions and 17 deletions
|
@ -45,16 +45,22 @@ class SSHKeyController extends ClientApiController
|
|||
/**
|
||||
* Deletes an SSH key from the user's account.
|
||||
*/
|
||||
public function delete(ClientApiRequest $request, string $identifier): JsonResponse
|
||||
public function delete(ClientApiRequest $request): JsonResponse
|
||||
{
|
||||
$key = $request->user()->sshKeys()->where('fingerprint', $identifier)->firstOrFail();
|
||||
$this->validate($request, ['fingerprint' => ['required', 'string']]);
|
||||
|
||||
$key->delete();
|
||||
$key = $request->user()->sshKeys()
|
||||
->where('fingerprint', $request->input('fingerprint'))
|
||||
->first();
|
||||
|
||||
Activity::event('user:ssh-key.delete')
|
||||
->subject($key)
|
||||
->property('fingerprint', $key->fingerprint)
|
||||
->log();
|
||||
if (!is_null($key)) {
|
||||
$key->delete();
|
||||
|
||||
Activity::event('user:ssh-key.delete')
|
||||
->subject($key)
|
||||
->property('fingerprint', $key->fingerprint)
|
||||
->log();
|
||||
}
|
||||
|
||||
return new JsonResponse([], JsonResponse::HTTP_NO_CONTENT);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue