mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-12 06:59:04 +02:00
Handle missing 2FAccount when deleting
This commit is contained in:
@ -118,8 +118,12 @@ class TwoFAccountController extends Controller
|
|||||||
* @param \App\TwoFAccount $twofaccount
|
* @param \App\TwoFAccount $twofaccount
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function destroy(TwoFAccount $twofaccount)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
|
|
||||||
|
$twofaccount = TwoFAccount::FindOrFail($id);
|
||||||
|
|
||||||
// delete icon
|
// delete icon
|
||||||
$storedIcon = 'public/icons/' . $twofaccount->icon;
|
$storedIcon = 'public/icons/' . $twofaccount->icon;
|
||||||
|
|
||||||
@ -130,6 +134,13 @@ class TwoFAccountController extends Controller
|
|||||||
$twofaccount->delete();
|
$twofaccount->delete();
|
||||||
|
|
||||||
return response()->json(null, 204);
|
return response()->json(null, 204);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (\Exception $e) {
|
||||||
|
|
||||||
|
return response()->json('already gone', 404);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -169,12 +169,12 @@
|
|||||||
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
||||||
axios.defaults.headers.common['Authorization'] = 'Bearer ' + this.token
|
axios.defaults.headers.common['Authorization'] = 'Bearer ' + this.token
|
||||||
|
|
||||||
axios.delete('/api/twofaccounts/' + id).then(response => {
|
axios.delete('/api/twofaccounts/' + id)
|
||||||
|
|
||||||
this.accounts.splice(this.accounts.findIndex(x => x.id === id), 1);
|
this.accounts.splice(this.accounts.findIndex(x => x.id === id), 1);
|
||||||
|
|
||||||
this.showAccounts = this.accounts.length > 0 ? true : false
|
this.showAccounts = this.accounts.length > 0 ? true : false
|
||||||
this.showNoAccount = !this.showAccounts
|
this.showNoAccount = !this.showAccounts
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user