feat(service): huỷ dịch vụ, SSL, đổi mật khẩu hosting, lịch sử thanh toán theo hình thức
- Lịch sử thanh toán hoá đơn trả thêm `method` (tự động gia hạn / số dư / admin / chuyển khoản / hoàn tiền), bỏ đuôi `(method)` khỏi ghi chú - `DnsServer::panelUrl()` = https://<domain>/ dùng cho email cấp hosting và nút Plesk của khách - Order item trả thêm `uuid`/`type` của dịch vụ để FE dẫn tới trang quản lý - Yêu cầu huỷ dịch vụ, chứng chỉ SSL, lịch sử gia hạn, đổi mật khẩu hosting cho khách Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
a6b641015e
commit
b44a88bb52
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Client\Service;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ModuleHostingPleskClient;
|
||||
use App\Models\Service;
|
||||
use App\Services\Plesk\PleskClientService;
|
||||
use App\Support\ClientPassword;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HostingPasswordController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, string $uuid, PleskClientService $plesk): JsonResponse
|
||||
{
|
||||
$data = $request->validate(
|
||||
['password' => ['required', 'string', 'max:64', 'confirmed', ClientPassword::rule()]],
|
||||
['password.min' => ClientPassword::minMessage()],
|
||||
);
|
||||
|
||||
$hosting = Service::with('hostingAccount.server')
|
||||
->where('uuid', $uuid)
|
||||
->where('customer_id', $request->user()->id)
|
||||
->where('status', 'active')
|
||||
->first()?->hostingAccount;
|
||||
|
||||
$client = $hosting ? ModuleHostingPleskClient::forHosting($hosting) : null;
|
||||
|
||||
if (!$client || !$hosting->server) {
|
||||
return response()->json(['error' => true, 'message' => 'Không tìm thấy dịch vụ hosting'], 404);
|
||||
}
|
||||
|
||||
if (!$plesk->changePassword($hosting->server, $client, $data['password'])) {
|
||||
return response()->json(['error' => true, 'message' => 'Plesk từ chối mật khẩu mới. Hãy dùng mật khẩu mạnh hơn (chữ hoa, chữ thường, số, ký tự đặc biệt).'], 422);
|
||||
}
|
||||
|
||||
return response()->json(['error' => false, 'message' => 'Đã đổi mật khẩu Plesk']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user