feat: tg/ws/security/
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Admin;
|
||||
use App\Models\Channel;
|
||||
use App\Models\SystemLog;
|
||||
use App\Models\User;
|
||||
use App\Services\TelegramNotifier;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -55,6 +57,9 @@ class AgentUserController extends Controller
|
||||
'chat_id' => $u->chat_id ?: '',
|
||||
'telegram_ready' => $u->hasTelegramChat(),
|
||||
'google_bound' => $u->hasGoogleBound() ? 1 : 0,
|
||||
'login_attempts' => (int) $u->login_attempts,
|
||||
'locked_at' => optional($u->locked_at)->format('Y-m-d H:i:s'),
|
||||
'is_locked' => $u->isLocked(),
|
||||
'channels_count' => (int) $u->channels_count,
|
||||
'auto_transfer_enabled' => (int) $u->auto_transfer_enabled,
|
||||
'auto_transfer_threshold_usdt' => $u->auto_transfer_threshold_usdt !== null ? (string) $u->auto_transfer_threshold_usdt : '',
|
||||
@@ -167,6 +172,31 @@ class AgentUserController extends Controller
|
||||
return response()->json(['code' => 0, 'msg' => 'ok']);
|
||||
}
|
||||
|
||||
public function unlock(User $agent)
|
||||
{
|
||||
/** @var Admin|null $actor */
|
||||
$actor = auth('admin')->user();
|
||||
if (! $actor instanceof Admin) {
|
||||
return response()->json(['code' => 1, 'msg' => '未登录'], 401);
|
||||
}
|
||||
|
||||
if (! $agent->isLocked()) {
|
||||
return response()->json(['code' => 1, 'msg' => '该账号未被封禁']);
|
||||
}
|
||||
|
||||
$agent->clearLoginAttempts();
|
||||
|
||||
SystemLog::record(
|
||||
$actor,
|
||||
'admin',
|
||||
SystemLog::ACTION_AGENT_UNLOCKED,
|
||||
'管理员「'.$actor->username.'」解除代理「'.$agent->username.'」的封禁状态',
|
||||
request(),
|
||||
);
|
||||
|
||||
return response()->json(['code' => 0, 'msg' => '已解除封禁']);
|
||||
}
|
||||
|
||||
public function testTelegram(Request $request, TelegramNotifier $telegram)
|
||||
{
|
||||
$data = $request->validate([
|
||||
|
||||
Reference in New Issue
Block a user