mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-05 18:23:48 +00:00
Fixed issue when after deleting user, the related subscription wasn't deleted
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=base64:9wVs/t3WU5njVGevkgDgGY8aKKkzsxkwykf3Pr0aQHc=
|
||||
APP_KEY=base64:O3Cn1MQIeqjOtDEcU8L8FBB50VHqqr6vyBeCN3Qn47U=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
APP_DEMO=false
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
## Version 2.2.0.9
|
||||
#### Release date: 22. Jun 2022
|
||||
- Set sandbox/live mode in PayPal key configuration setup form
|
||||
- Fixed issue when after deleting user, the related subscription wasn't deleted
|
||||
|
||||
## Version 2.2.0.6
|
||||
#### Release date: 13. Jun 2022
|
||||
- Solved issue when user wasn't redirected into stripe checkout
|
||||
|
||||
56
composer.lock
generated
56
composer.lock
generated
@@ -280,16 +280,16 @@
|
||||
},
|
||||
{
|
||||
"name": "aws/aws-sdk-php",
|
||||
"version": "3.227.0",
|
||||
"version": "3.228.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/aws/aws-sdk-php.git",
|
||||
"reference": "88d803113ade68604ec03c591d65e1e44406ab8e"
|
||||
"reference": "4ff51d01da43aa3bd36eef921a9cd4e0ff843fab"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/88d803113ade68604ec03c591d65e1e44406ab8e",
|
||||
"reference": "88d803113ade68604ec03c591d65e1e44406ab8e",
|
||||
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/4ff51d01da43aa3bd36eef921a9cd4e0ff843fab",
|
||||
"reference": "4ff51d01da43aa3bd36eef921a9cd4e0ff843fab",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -365,9 +365,9 @@
|
||||
"support": {
|
||||
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
|
||||
"issues": "https://github.com/aws/aws-sdk-php/issues",
|
||||
"source": "https://github.com/aws/aws-sdk-php/tree/3.227.0"
|
||||
"source": "https://github.com/aws/aws-sdk-php/tree/3.228.0"
|
||||
},
|
||||
"time": "2022-06-17T18:15:06+00:00"
|
||||
"time": "2022-06-21T18:13:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "bacon/bacon-qr-code",
|
||||
@@ -2633,22 +2633,22 @@
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/guzzle",
|
||||
"version": "7.4.4",
|
||||
"version": "7.4.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/guzzle.git",
|
||||
"reference": "e3ff079b22820c2029d4c2a87796b6a0b8716ad8"
|
||||
"reference": "1dd98b0564cb3f6bd16ce683cb755f94c10fbd82"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/e3ff079b22820c2029d4c2a87796b6a0b8716ad8",
|
||||
"reference": "e3ff079b22820c2029d4c2a87796b6a0b8716ad8",
|
||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/1dd98b0564cb3f6bd16ce683cb755f94c10fbd82",
|
||||
"reference": "1dd98b0564cb3f6bd16ce683cb755f94c10fbd82",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"guzzlehttp/promises": "^1.5",
|
||||
"guzzlehttp/psr7": "^1.8.3 || ^2.1",
|
||||
"guzzlehttp/psr7": "^1.9 || ^2.4",
|
||||
"php": "^7.2.5 || ^8.0",
|
||||
"psr/http-client": "^1.0",
|
||||
"symfony/deprecation-contracts": "^2.2 || ^3.0"
|
||||
@@ -2737,7 +2737,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/guzzle/guzzle/issues",
|
||||
"source": "https://github.com/guzzle/guzzle/tree/7.4.4"
|
||||
"source": "https://github.com/guzzle/guzzle/tree/7.4.5"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -2753,7 +2753,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2022-06-09T21:39:15+00:00"
|
||||
"time": "2022-06-20T22:16:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/promises",
|
||||
@@ -2841,16 +2841,16 @@
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/psr7",
|
||||
"version": "2.3.0",
|
||||
"version": "2.4.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/psr7.git",
|
||||
"reference": "83260bb50b8fc753c72d14dc1621a2dac31877ee"
|
||||
"reference": "13388f00956b1503577598873fffb5ae994b5737"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/83260bb50b8fc753c72d14dc1621a2dac31877ee",
|
||||
"reference": "83260bb50b8fc753c72d14dc1621a2dac31877ee",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/13388f00956b1503577598873fffb5ae994b5737",
|
||||
"reference": "13388f00956b1503577598873fffb5ae994b5737",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -2874,7 +2874,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.3-dev"
|
||||
"dev-master": "2.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -2936,7 +2936,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/guzzle/psr7/issues",
|
||||
"source": "https://github.com/guzzle/psr7/tree/2.3.0"
|
||||
"source": "https://github.com/guzzle/psr7/tree/2.4.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -2952,7 +2952,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2022-06-09T08:26:02+00:00"
|
||||
"time": "2022-06-20T21:43:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "intervention/image",
|
||||
@@ -3284,16 +3284,16 @@
|
||||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v9.17.0",
|
||||
"version": "v9.18.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/framework.git",
|
||||
"reference": "091e287678ac723c591509ca6374e4ded4a99b1c"
|
||||
"reference": "93a1296bca43c1ca8dcb5df8f97107e819a71499"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/091e287678ac723c591509ca6374e4ded4a99b1c",
|
||||
"reference": "091e287678ac723c591509ca6374e4ded4a99b1c",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/93a1296bca43c1ca8dcb5df8f97107e819a71499",
|
||||
"reference": "93a1296bca43c1ca8dcb5df8f97107e819a71499",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3305,7 +3305,7 @@
|
||||
"fruitcake/php-cors": "^1.2",
|
||||
"laravel/serializable-closure": "^1.0",
|
||||
"league/commonmark": "^2.2",
|
||||
"league/flysystem": "^3.0",
|
||||
"league/flysystem": "^3.0.16",
|
||||
"monolog/monolog": "^2.0",
|
||||
"nesbot/carbon": "^2.53.1",
|
||||
"php": "^8.0.2",
|
||||
@@ -3381,7 +3381,7 @@
|
||||
"pda/pheanstalk": "^4.0",
|
||||
"phpstan/phpstan": "^1.4.7",
|
||||
"phpunit/phpunit": "^9.5.8",
|
||||
"predis/predis": "^1.1.9",
|
||||
"predis/predis": "^1.1.9|^2.0",
|
||||
"symfony/cache": "^6.0"
|
||||
},
|
||||
"suggest": {
|
||||
@@ -3407,7 +3407,7 @@
|
||||
"nyholm/psr7": "Required to use PSR-7 bridging features (^1.2).",
|
||||
"pda/pheanstalk": "Required to use the beanstalk queue driver (^4.0).",
|
||||
"phpunit/phpunit": "Required to use assertions and run tests (^9.5.8).",
|
||||
"predis/predis": "Required to use the predis connector (^1.1.9).",
|
||||
"predis/predis": "Required to use the predis connector (^1.1.9|^2.0).",
|
||||
"psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).",
|
||||
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^6.0|^7.0).",
|
||||
"symfony/cache": "Required to PSR-6 cache bridge (^6.0).",
|
||||
@@ -3459,7 +3459,7 @@
|
||||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"time": "2022-06-07T15:09:32+00:00"
|
||||
"time": "2022-06-21T14:40:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/sanctum",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Domain\Admin\Actions;
|
||||
|
||||
use DB;
|
||||
@@ -22,15 +23,27 @@ class DeleteUserDataAction
|
||||
Storage::deleteDirectory("files/$user->id");
|
||||
|
||||
// Delete user subscriptions
|
||||
if ($user->subscription) {
|
||||
$user->subscription->delete();
|
||||
}
|
||||
$user->subscription?->delete();
|
||||
|
||||
// Delete all user records in database
|
||||
collect(['folders', 'files', 'user_settings', 'shares', 'favourite_folder', 'traffic'])
|
||||
collect([
|
||||
'team_folder_members',
|
||||
'favourite_folder',
|
||||
'user_limitations',
|
||||
'upload_requests',
|
||||
'billing_alerts',
|
||||
'user_settings',
|
||||
'credit_cards',
|
||||
'customers',
|
||||
//'dunnings',
|
||||
'folders',
|
||||
'traffic',
|
||||
'shares',
|
||||
'files',
|
||||
])
|
||||
->each(function ($table) use ($user) {
|
||||
DB::table($table)
|
||||
->whereUserId($user->id)
|
||||
->where('user_id', $user->id)
|
||||
->delete();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class DeleteUserController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
if ($user->subscription && $user->subscription->active()) {
|
||||
if ($user->subscription && $user->subscription->type === 'fixed' && $user->subscription->active()) {
|
||||
abort(
|
||||
response()->json([
|
||||
'type' => 'error',
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Domain\Admin;
|
||||
|
||||
use Storage;
|
||||
@@ -11,6 +12,7 @@ use Domain\Sharing\Models\Share;
|
||||
use Domain\Folders\Models\Folder;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use App\Users\Notifications\ResetPassword;
|
||||
use VueFileManager\Subscription\Domain\Subscriptions\Models\Subscription;
|
||||
|
||||
class AdminTest extends TestCase
|
||||
{
|
||||
@@ -44,8 +46,7 @@ class AdminTest extends TestCase
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$users->each(
|
||||
fn ($user) =>
|
||||
$this
|
||||
fn($user) => $this
|
||||
->actingAs($admin)
|
||||
->getJson('/api/admin/users?page=1')
|
||||
->assertStatus(200)
|
||||
@@ -169,7 +170,7 @@ class AdminTest extends TestCase
|
||||
])->assertStatus(200);
|
||||
|
||||
$this->assertDatabaseHas('user_settings', [
|
||||
'user_id' => $user->id,
|
||||
'user_id' => $user->id,
|
||||
])->assertDatabaseHas('user_limitations', [
|
||||
'max_storage_amount' => 10,
|
||||
]);
|
||||
@@ -214,13 +215,13 @@ class AdminTest extends TestCase
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->postJson('/api/admin/users', [
|
||||
'name' => 'John Doe',
|
||||
'role' => 'user',
|
||||
'email' => 'john@doe.com',
|
||||
'password' => 'VerySecretPassword',
|
||||
'max_storage_amount' => 15,
|
||||
'password_confirmation' => 'VerySecretPassword',
|
||||
'avatar' => $avatar,
|
||||
'name' => 'John Doe',
|
||||
'role' => 'user',
|
||||
'email' => 'john@doe.com',
|
||||
'password' => 'VerySecretPassword',
|
||||
'max_storage_amount' => 15,
|
||||
'password_confirmation' => 'VerySecretPassword',
|
||||
'avatar' => $avatar,
|
||||
])->assertStatus(201);
|
||||
|
||||
$this->assertDatabaseHas('users', [
|
||||
@@ -235,7 +236,10 @@ class AdminTest extends TestCase
|
||||
'last_name' => 'Doe',
|
||||
]);
|
||||
|
||||
$avatar = User::whereEmail('john@doe.com')->first()->settings->getRawOriginal('avatar');
|
||||
$avatar = User::where('email', 'john@doe.com')
|
||||
->first()
|
||||
->settings
|
||||
->getRawOriginal('avatar');
|
||||
|
||||
collect(config('vuefilemanager.avatar_sizes'))
|
||||
->each(
|
||||
@@ -257,6 +261,15 @@ class AdminTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
// Create subscription
|
||||
Subscription::factory()
|
||||
->hasDriver()
|
||||
->create([
|
||||
'user_id' => $user->id,
|
||||
'type' => 'pre-paid',
|
||||
'status' => 'active',
|
||||
]);
|
||||
|
||||
// Create folders
|
||||
$folders = Folder::factory()
|
||||
->count(2)
|
||||
@@ -279,10 +292,10 @@ class AdminTest extends TestCase
|
||||
->create("fake-file-$index.pdf", 1200, 'application/pdf');
|
||||
|
||||
$this->postJson('/api/upload/chunks', [
|
||||
'name' => $file->name,
|
||||
'extension' => 'pdf',
|
||||
'chunk' => $file,
|
||||
'is_last_chunk' => 1,
|
||||
'name' => $file->name,
|
||||
'extension' => 'pdf',
|
||||
'chunk' => $file,
|
||||
'is_last_chunk' => 1,
|
||||
])->assertStatus(201);
|
||||
});
|
||||
|
||||
@@ -304,33 +317,33 @@ class AdminTest extends TestCase
|
||||
$admin = User::factory()
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
// Delete user
|
||||
$this->deleteJson("/api/admin/users/$user->id/delete", [
|
||||
'name' => $user->settings->name,
|
||||
])
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->deleteJson("/api/admin/users/$user->id", [
|
||||
'name' => $user->settings->name,
|
||||
])
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertDatabaseMissing('user_settings', [
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseMissing('folders', [
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseMissing('shares', [
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseMissing('favourite_folder', [
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseMissing('files', [
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
$this
|
||||
->assertDatabaseMissing('subscriptions', [
|
||||
'user_id' => $user->id,
|
||||
])
|
||||
->assertDatabaseMissing('user_settings', [
|
||||
'user_id' => $user->id,
|
||||
])
|
||||
->assertDatabaseMissing('folders', [
|
||||
'user_id' => $user->id,
|
||||
])
|
||||
->assertDatabaseMissing('shares', [
|
||||
'user_id' => $user->id,
|
||||
])
|
||||
->assertDatabaseMissing('favourite_folder', [
|
||||
'user_id' => $user->id,
|
||||
])
|
||||
->assertDatabaseMissing('files', [
|
||||
'user_id' => $user->id,
|
||||
]);
|
||||
|
||||
$file_ids
|
||||
->each(function ($id, $index) use ($user) {
|
||||
@@ -346,6 +359,6 @@ class AdminTest extends TestCase
|
||||
});
|
||||
|
||||
Storage::disk('local')
|
||||
->assertMissing($user->settings->getRawOriginal('avatar'));
|
||||
->assertMissing($user->settings->avatar);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user