mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-31 18:28:54 +00:00
25 lines
660 B
PHP
25 lines
660 B
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
use App\Models\Settings;
|
|
use App\Mail\AccountDeleted;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Mail;
|
|
|
|
if (! Auth::check()) {
|
|
$page->show403();
|
|
}
|
|
|
|
$userId = request()->input('id');
|
|
|
|
if ($userId !== null && $page->userdata->role->id !== User::ROLE_ADMIN && (int) $userId === Auth::id()) {
|
|
Mail::to(Settings::settingValue('site.main.email'))->send(new AccountDeleted($userId));
|
|
Auth::logout();
|
|
User::deleteUser($userId);
|
|
header('Location:'.WWW_TOP.'/login');
|
|
} elseif ($page->userdata->role->id === User::ROLE_ADMIN) {
|
|
redirect(WWW_TOP.'profile');
|
|
} else {
|
|
$page->showBadBoy();
|
|
}
|