mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-02-22 21:30:56 +01:00
Handle missing 2FAccount when deleting
This commit is contained in:
parent
7b5ac91796
commit
aaab76b7d3
@ -118,18 +118,29 @@ public function update(Request $request, TwoFAccount $twofaccount)
|
||||
* @param \App\TwoFAccount $twofaccount
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(TwoFAccount $twofaccount)
|
||||
public function destroy($id)
|
||||
{
|
||||
// delete icon
|
||||
$storedIcon = 'public/icons/' . $twofaccount->icon;
|
||||
try {
|
||||
|
||||
$twofaccount = TwoFAccount::FindOrFail($id);
|
||||
|
||||
// delete icon
|
||||
$storedIcon = 'public/icons/' . $twofaccount->icon;
|
||||
|
||||
if( Storage::exists($storedIcon) ) {
|
||||
Storage::delete($storedIcon);
|
||||
}
|
||||
|
||||
$twofaccount->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
|
||||
if( Storage::exists($storedIcon) ) {
|
||||
Storage::delete($storedIcon);
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
|
||||
$twofaccount->delete();
|
||||
return response()->json('already gone', 404);
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -169,12 +169,12 @@
|
||||
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
||||
axios.defaults.headers.common['Authorization'] = 'Bearer ' + this.token
|
||||
|
||||
axios.delete('/api/twofaccounts/' + id).then(response => {
|
||||
this.accounts.splice(this.accounts.findIndex(x => x.id === id), 1);
|
||||
axios.delete('/api/twofaccounts/' + id)
|
||||
|
||||
this.showAccounts = this.accounts.length > 0 ? true : false
|
||||
this.showNoAccount = !this.showAccounts
|
||||
})
|
||||
this.accounts.splice(this.accounts.findIndex(x => x.id === id), 1);
|
||||
|
||||
this.showAccounts = this.accounts.length > 0 ? true : false
|
||||
this.showNoAccount = !this.showAccounts
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user