Update AdminUserController, add account deletion handler

This commit is contained in:
Daniel Supernault 2020-02-19 22:55:10 -07:00
parent 826978ce08
commit 9be19ad880
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -10,6 +10,7 @@ use App\User;
use App\Mail\AdminMessage;
use Illuminate\Support\Facades\Mail;
use App\Services\ModLogService;
use App\Jobs\DeletePipeline\DeleteAccountPipeline;
trait AdminUserController
{
@ -157,6 +158,35 @@ trait AdminUserController
return view('admin.users.delete', compact('user', 'profile'));
}
public function userDeleteProcess(Request $request, $id)
{
$user = User::findOrFail($id);
$profile = $user->profile;
if(config('pixelfed.account_deletion') == false) {
abort(404);
}
if($user->is_admin == true) {
$mid = $request->user()->id;
abort_if($user->id < $mid, 403);
}
$ts = now()->addMonth();
$user->status = 'delete';
$profile->status = 'delete';
$user->delete_after = $ts;
$profile->delete_after = $ts;
$user->save();
$profile->save();
Cache::forget('profiles:private');
DeleteAccountPipeline::dispatch($user)->onQueue('high');
$msg = "Successfully deleted {$user->username}!";
$request->session()->flash('status', $msg);
return redirect('/i/admin/users/list');
}
public function userModerate(Request $request)
{
$this->validate($request, [