Changeset View
Changeset View
Standalone View
Standalone View
src/app/Observers/UserObserver.php
Show First 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | public function updated(User $user) | ||||
->where('entitleable_id', '!=', $user->id) | ->where('entitleable_id', '!=', $user->id) | ||||
->where('entitleable_type', User::class) | ->where('entitleable_type', User::class) | ||||
->pluck('entitleable_id') | ->pluck('entitleable_id') | ||||
->unique() | ->unique() | ||||
->each(function ($user_id) { | ->each(function ($user_id) { | ||||
\App\Jobs\User\UpdateJob::dispatch($user_id); | \App\Jobs\User\UpdateJob::dispatch($user_id); | ||||
}); | }); | ||||
} | } | ||||
// Save the old password in the password history | |||||
$oldPassword = $user->getOriginal('password'); | |||||
if ($oldPassword && $user->password != $oldPassword) { | |||||
$user->passwords()->create(['password' => $oldPassword]); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
* Remove entitleables/transactions related to the user (in user's wallets) | * Remove entitleables/transactions related to the user (in user's wallets) | ||||
* | * | ||||
* @param \App\User $user The user | * @param \App\User $user The user | ||||
* @param bool $force Force-delete mode | * @param bool $force Force-delete mode | ||||
*/ | */ | ||||
Show All 30 Lines | private static function removeRelatedObjects(User $user, $force = false): void | ||||
// regardless of force delete, we're always purging whitelists... just in case | // regardless of force delete, we're always purging whitelists... just in case | ||||
\App\Policy\RateLimitWhitelist::where( | \App\Policy\RateLimitWhitelist::where( | ||||
[ | [ | ||||
'whitelistable_id' => $user->id, | 'whitelistable_id' => $user->id, | ||||
'whitelistable_type' => User::class | 'whitelistable_type' => User::class | ||||
] | ] | ||||
)->delete(); | )->delete(); | ||||
} | } | ||||
} | } | ||||
mollekopf: I would make this a >= just to be safe (even if we technically *shouldn't* ever get there). |
I would make this a >= just to be safe (even if we technically *shouldn't* ever get there).