feat: popup quảng cáo, đặt lại mật khẩu bằng token 80 ký tự, 2FA email, vá lỗ hổng bảo mật
- Popup/banner quảng cáo cấu hình từ admin (loại, link, lịch hiển thị) - Đặt lại mật khẩu: token 80 ký tự kèm check digit Luhn thay cho token+email lộ trong URL, chỉ lưu bản băm, một lần dùng, hết hạn 60 phút - Xác thực 2 lớp qua email khi đăng nhập (mã 6 số, ghi nhớ thiết bị 90 ngày) - ApiAuthCheck chặn ngay tài khoản bị khoá dù JWT còn hạn (trước đây dùng được tới hết TTL) - Handler trả 404 thay vì 500 khi ModelNotFoundException không bọc HttpException - Test ClientTamperingTest: xác nhận IDOR/giả mạo dữ liệu từ client đều bị chặn Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
e888a6ed5d
commit
12d5b4951c
@@ -3,7 +3,7 @@
|
||||
namespace App\Http\Controllers\Api\Client\Concerns;
|
||||
|
||||
use App\Http\Requests\Api\Client\ClientChangePasswordRequest;
|
||||
use App\Models\Customer;
|
||||
use App\Support\PasswordResetToken;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
@@ -33,15 +33,28 @@ trait HandlesClientPasswordReset
|
||||
]);
|
||||
}
|
||||
|
||||
public function showResetToken(string $token)
|
||||
{
|
||||
$customer = PasswordResetToken::findCustomer($token);
|
||||
|
||||
if (!$customer) {
|
||||
return response()->json([
|
||||
'error' => true,
|
||||
'message' => 'Link đặt lại mật khẩu không hợp lệ hoặc đã hết hạn.',
|
||||
], 404);
|
||||
}
|
||||
|
||||
return response()->json(['error' => false, 'data' => ['email' => $customer->email]]);
|
||||
}
|
||||
|
||||
public function resetPassword(Request $request)
|
||||
{
|
||||
$data = $request->validate([
|
||||
'email' => ['required', 'email', 'max:255'],
|
||||
'token' => ['required', 'string', 'max:255'],
|
||||
'token' => ['required', 'string', 'size:' . PasswordResetToken::LENGTH],
|
||||
'password' => ['required', Password::min(10), 'confirmed'],
|
||||
]);
|
||||
|
||||
$customer = $this->authService->resetPassword($data);
|
||||
$customer = $this->authService->resetPassword($data['token'], $data['password']);
|
||||
|
||||
$this->activityLogger->log(
|
||||
event: 'password_reset',
|
||||
|
||||
Reference in New Issue
Block a user