mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-22 08:13:11 +01:00
Remove softDelete on 2FAccounts
This commit is contained in:
parent
eab03e6d0c
commit
3a0bf1a596
@ -7,6 +7,7 @@
|
||||
use OTPHP\Factory;
|
||||
use Illuminate\Http\Request;
|
||||
use ParagonIE\ConstantTime\Base32;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class TwoFAccountController extends Controller
|
||||
{
|
||||
@ -106,24 +107,16 @@ public function update(Request $request, TwoFAccount $twofaccount)
|
||||
*/
|
||||
public function destroy(TwoFAccount $twofaccount)
|
||||
{
|
||||
// delete icon
|
||||
$storedIcon = 'public/' . pathinfo($twofaccount->icon)['basename'];
|
||||
|
||||
if( Storage::exists($storedIcon) ) {
|
||||
Storage::delete($storedIcon);
|
||||
}
|
||||
|
||||
$twofaccount->delete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove the specified soft deleted resource from storage.
|
||||
*
|
||||
* @param \App\TwoFAccount $twofaccount
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function forceDestroy($id)
|
||||
{
|
||||
$twofaccount = TwoFAccount::onlyTrashed()->findOrFail($id);
|
||||
$twofaccount->forceDelete();
|
||||
|
||||
return response()->json(null, 204);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,11 +3,9 @@
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class TwoFAccount extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $fillable = ['service', 'account', 'uri', 'icon'];
|
||||
|
||||
|
@ -20,7 +20,6 @@ public function up()
|
||||
$table->string('account');
|
||||
$table->string('icon')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -23,5 +23,4 @@
|
||||
Route::get('twofaccounts/{twofaccount}/totp', 'TwoFAccountController@generateTOTP')->name('twofaccounts.generateTOTP');
|
||||
Route::post('qrcode/decode', 'QrCodeController@decode');
|
||||
Route::post('icon/upload', 'IconController@upload');
|
||||
Route::delete('twofaccounts/force/{id}', 'TwoFAccountController@forceDestroy')->name('twofaccounts.forceDestroy');
|
||||
});
|
@ -135,20 +135,4 @@ public function testTwoFAccountDeletion()
|
||||
->assertStatus(204);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test TwoFAccount permanent deletion via API
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function testTwoFAccountPermanentDeletion()
|
||||
{
|
||||
$twofaccount = factory(TwoFAccount::class)->create();
|
||||
$twofaccount->delete();
|
||||
|
||||
$response = $this->actingAs($this->user, 'api')
|
||||
->json('DELETE', '/api/twofaccounts/force/' . $twofaccount->id)
|
||||
->assertStatus(204);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user