v1.5.6 User images is now deleted for the uploads folder when a user is deleted or gets a new one

This commit is contained in:
Neerholt 2021-04-08 15:27:01 +02:00
parent 4a13c17ab2
commit e3aea65ec5
6 changed files with 2022 additions and 1111 deletions

View File

@ -77,7 +77,6 @@
<path value="$PROJECT_DIR$/skolehjem/vendor/jaybizzle/crawler-detect" /> <path value="$PROJECT_DIR$/skolehjem/vendor/jaybizzle/crawler-detect" />
<path value="$PROJECT_DIR$/skolehjem/vendor/jenssegers/agent" /> <path value="$PROJECT_DIR$/skolehjem/vendor/jenssegers/agent" />
<path value="$PROJECT_DIR$/skolehjem/vendor/mobiledetect/mobiledetectlib" /> <path value="$PROJECT_DIR$/skolehjem/vendor/mobiledetect/mobiledetectlib" />
<path value="$PROJECT_DIR$/skolehjem/vendor/scrivo/highlight.php" />
<path value="$PROJECT_DIR$/skolehjem/vendor/filp/whoops" /> <path value="$PROJECT_DIR$/skolehjem/vendor/filp/whoops" />
<path value="$PROJECT_DIR$/skolehjem/vendor/facade/ignition-contracts" /> <path value="$PROJECT_DIR$/skolehjem/vendor/facade/ignition-contracts" />
<path value="$PROJECT_DIR$/skolehjem/vendor/facade/flare-client-php" /> <path value="$PROJECT_DIR$/skolehjem/vendor/facade/flare-client-php" />
@ -86,9 +85,7 @@
<path value="$PROJECT_DIR$/skolehjem/vendor/webmozart/assert" /> <path value="$PROJECT_DIR$/skolehjem/vendor/webmozart/assert" />
<path value="$PROJECT_DIR$/skolehjem/vendor/fzaninotto/faker" /> <path value="$PROJECT_DIR$/skolehjem/vendor/fzaninotto/faker" />
<path value="$PROJECT_DIR$/skolehjem/vendor/facade/ignition" /> <path value="$PROJECT_DIR$/skolehjem/vendor/facade/ignition" />
<path value="$PROJECT_DIR$/skolehjem/vendor/phpunit/php-timer" />
<path value="$PROJECT_DIR$/skolehjem/vendor/phpunit/php-code-coverage" /> <path value="$PROJECT_DIR$/skolehjem/vendor/phpunit/php-code-coverage" />
<path value="$PROJECT_DIR$/skolehjem/vendor/phpunit/php-file-iterator" />
<path value="$PROJECT_DIR$/skolehjem/vendor/phpunit/php-text-template" /> <path value="$PROJECT_DIR$/skolehjem/vendor/phpunit/php-text-template" />
<path value="$PROJECT_DIR$/skolehjem/vendor/phpunit/php-token-stream" /> <path value="$PROJECT_DIR$/skolehjem/vendor/phpunit/php-token-stream" />
<path value="$PROJECT_DIR$/skolehjem/vendor/sebastian/version" /> <path value="$PROJECT_DIR$/skolehjem/vendor/sebastian/version" />
@ -124,7 +121,6 @@
<path value="$PROJECT_DIR$/skolehjem/vendor/sabberworm/php-css-parser" /> <path value="$PROJECT_DIR$/skolehjem/vendor/sabberworm/php-css-parser" />
<path value="$PROJECT_DIR$/skolehjem/vendor/phenx/php-svg-lib" /> <path value="$PROJECT_DIR$/skolehjem/vendor/phenx/php-svg-lib" />
<path value="$PROJECT_DIR$/skolehjem/vendor/spomky-labs/base64url" /> <path value="$PROJECT_DIR$/skolehjem/vendor/spomky-labs/base64url" />
<path value="$PROJECT_DIR$/skolehjem/vendor/thecodingmachine/safe" />
<path value="$PROJECT_DIR$/skolehjem/vendor/laravel-notification-channels/webpush" /> <path value="$PROJECT_DIR$/skolehjem/vendor/laravel-notification-channels/webpush" />
<path value="$PROJECT_DIR$/skolehjem/vendor/minishlink/web-push" /> <path value="$PROJECT_DIR$/skolehjem/vendor/minishlink/web-push" />
<path value="$PROJECT_DIR$/skolehjem/vendor/psr/http-client" /> <path value="$PROJECT_DIR$/skolehjem/vendor/psr/http-client" />
@ -139,6 +135,9 @@
<path value="$PROJECT_DIR$/skolehjem/vendor/laminas/laminas-zendframework-bridge" /> <path value="$PROJECT_DIR$/skolehjem/vendor/laminas/laminas-zendframework-bridge" />
<path value="$PROJECT_DIR$/skolehjem/vendor/lcobucci/jwt" /> <path value="$PROJECT_DIR$/skolehjem/vendor/lcobucci/jwt" />
<path value="$PROJECT_DIR$/skolehjem/vendor/php-http/message-factory" /> <path value="$PROJECT_DIR$/skolehjem/vendor/php-http/message-factory" />
<path value="$PROJECT_DIR$/skolehjem/vendor/symfony/http-client-contracts" />
<path value="$PROJECT_DIR$/skolehjem/vendor/phpunit/php-timer" />
<path value="$PROJECT_DIR$/skolehjem/vendor/phpunit/php-file-iterator" />
</include_path> </include_path>
</component> </component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.2" /> <component name="PhpProjectSharedConfiguration" php_language_level="7.2" />

View File

@ -65,9 +65,7 @@
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/phpseclib/phpseclib" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/phpseclib/phpseclib" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/phpspec/prophecy" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/phpspec/prophecy" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/phpunit/php-code-coverage" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/phpunit/php-code-coverage" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/phpunit/php-file-iterator" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/phpunit/php-text-template" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/phpunit/php-text-template" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/phpunit/php-timer" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/phpunit/php-token-stream" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/phpunit/php-token-stream" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/phpunit/phpunit" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/phpunit/phpunit" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/psr/container" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/psr/container" />
@ -82,7 +80,6 @@
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/ramsey/collection" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/ramsey/collection" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/ramsey/uuid" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/ramsey/uuid" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/sabberworm/php-css-parser" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/sabberworm/php-css-parser" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/scrivo/highlight.php" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/sebastian/code-unit-reverse-lookup" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/sebastian/code-unit-reverse-lookup" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/sebastian/comparator" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/sebastian/comparator" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/sebastian/diff" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/sebastian/diff" />
@ -125,7 +122,6 @@
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/symfony/translation" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/symfony/translation" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/symfony/translation-contracts" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/symfony/translation-contracts" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/symfony/var-dumper" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/symfony/var-dumper" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/thecodingmachine/safe" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/theseer/tokenizer" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/theseer/tokenizer" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/tijsverkoyen/css-to-inline-styles" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/tijsverkoyen/css-to-inline-styles" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/vlucas/phpdotenv" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/vlucas/phpdotenv" />
@ -136,6 +132,9 @@
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/web-token/jwt-signature-algorithm-ecdsa" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/web-token/jwt-signature-algorithm-ecdsa" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/web-token/jwt-util-ecc" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/web-token/jwt-util-ecc" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/webmozart/assert" /> <excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/webmozart/assert" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/symfony/http-client-contracts" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/phpunit/php-timer" />
<excludeFolder url="file://$MODULE_DIR$/skolehjem/vendor/phpunit/php-file-iterator" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />

View File

@ -3,8 +3,10 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Helpers\Detector; use App\Helpers\Detector;
use App\Resource;
use App\ResourceCategory; use App\ResourceCategory;
use App\ResourceExtension; use App\ResourceExtension;
use FontLib\EOT\File;
use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Collection;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
@ -131,6 +133,9 @@ class UserController extends Controller
"user" => $user, "user" => $user,
"roles" => $roles, "roles" => $roles,
]); ]);
} }
/** /**
@ -147,11 +152,22 @@ class UserController extends Controller
$user = User::find($id); $user = User::find($id);
if($request->file("resource")) {
$user->resource_id = ResourceController::store($request)->id;
}
$user->save(); if($request->file("resource")) {
if(!empty($user->resource_id)){
$resource = Resource::find($user->resource_id);
unlink(public_path() . $resource->filename);
$user->resource_id = ResourceController::store($request)->id;
$user->save();
$resource->delete();
} else {
$user->resource_id = ResourceController::store($request)->id;
$user->save();
}
}
$allUsersEmail = User::query()->where('email', '=', $request->email)->where('id', '!=', $id)->get(); $allUsersEmail = User::query()->where('email', '=', $request->email)->where('id', '!=', $id)->get();
$allUsersPhone = User::query()->where('phone', '=', $request->phone)->where('id', '!=', $id)->get(); $allUsersPhone = User::query()->where('phone', '=', $request->phone)->where('id', '!=', $id)->get();

3041
skolehjem/composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1735,12 +1735,20 @@
} }
}, },
"axios": { "axios": {
"version": "0.19.2", "version": "0.21.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
"integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
"dev": true, "dev": true,
"requires": { "requires": {
"follow-redirects": "1.5.10" "follow-redirects": "^1.10.0"
},
"dependencies": {
"follow-redirects": {
"version": "1.13.3",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.3.tgz",
"integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA==",
"dev": true
}
} }
}, },
"babel-code-frame": { "babel-code-frame": {
@ -3397,24 +3405,24 @@
"dev": true "dev": true
}, },
"elliptic": { "elliptic": {
"version": "6.5.3", "version": "6.5.4",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz",
"integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==", "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"bn.js": "^4.4.0", "bn.js": "^4.11.9",
"brorand": "^1.0.1", "brorand": "^1.1.0",
"hash.js": "^1.0.0", "hash.js": "^1.0.0",
"hmac-drbg": "^1.0.0", "hmac-drbg": "^1.0.1",
"inherits": "^2.0.1", "inherits": "^2.0.4",
"minimalistic-assert": "^1.0.0", "minimalistic-assert": "^1.0.1",
"minimalistic-crypto-utils": "^1.0.0" "minimalistic-crypto-utils": "^1.0.1"
}, },
"dependencies": { "dependencies": {
"bn.js": { "bn.js": {
"version": "4.11.9", "version": "4.12.0",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz",
"integrity": "sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==", "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==",
"dev": true "dev": true
} }
} }
@ -4922,9 +4930,9 @@
"dev": true "dev": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.8",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==",
"dev": true "dev": true
}, },
"internal-ip": { "internal-ip": {
@ -10114,9 +10122,9 @@
"dev": true "dev": true
}, },
"y18n": { "y18n": {
"version": "4.0.0", "version": "4.0.3",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
"integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
"dev": true "dev": true
}, },
"yallist": { "yallist": {

View File

@ -11,7 +11,7 @@
}, },
"devDependencies": { "devDependencies": {
"@ckeditor/ckeditor5-inspector": "^2.2.0", "@ckeditor/ckeditor5-inspector": "^2.2.0",
"axios": "^0.19", "axios": "^0.21.1",
"cross-env": "^7.0", "cross-env": "^7.0",
"jquery": "^3.5.1", "jquery": "^3.5.1",
"laravel-mix": "^5.0.9", "laravel-mix": "^5.0.9",