Changeset View
Changeset View
Standalone View
Standalone View
src/app/Jobs/User/DeleteJob.php
Show All 9 Lines | class DeleteJob extends UserJob | ||||
* Execute the job. | * Execute the job. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function handle() | public function handle() | ||||
{ | { | ||||
$user = $this->getUser(); | $user = $this->getUser(); | ||||
if (!$user) { | |||||
return; | |||||
} | |||||
// sanity checks | // sanity checks | ||||
if ($user->isDeleted()) { | if ($user->isDeleted()) { | ||||
$this->fail(new \Exception("User {$this->userId} is already marked as deleted.")); | $this->fail(new \Exception("User {$this->userId} is already marked as deleted.")); | ||||
return; | |||||
} | } | ||||
\App\Backends\LDAP::deleteUser($user); | \App\Backends\LDAP::deleteUser($user); | ||||
$user->status |= \App\User::STATUS_DELETED; | $user->status |= \App\User::STATUS_DELETED; | ||||
$user->save(); | $user->save(); | ||||
} | } | ||||
} | } |