Some checks failed
Build and Deploy LittleShop / Build TeleBot Docker Image (push) Failing after 11s
Build and Deploy LittleShop / Build LittleShop Docker Image (push) Failing after 15s
Build and Deploy LittleShop / Deploy to Production VPS (Manual Only) (push) Has been skipped
Build and Deploy LittleShop / Deploy to Pre-Production (CT109) (push) Has been skipped
Major Feature Additions: - Customer management: Full CRUD with data export and privacy compliance - Payment management: Centralized payment tracking and administration - Push notification subscriptions: Manage and track web push subscriptions Security Enhancements: - IP whitelist middleware for administrative endpoints - Data retention service with configurable policies - Enhanced push notification security documentation - Security fixes progress tracking (2025-11-14) UI/UX Improvements: - Enhanced navigation with improved mobile responsiveness - Updated admin dashboard with order status counts - Improved product CRUD forms - New customer and payment management interfaces Backend Improvements: - Extended customer service with data export capabilities - Enhanced order service with status count queries - Improved crypto payment service with better error handling - Updated validators and configuration Documentation: - DEPLOYMENT_NGINX_GUIDE.md: Nginx deployment instructions - IP_STORAGE_ANALYSIS.md: IP storage security analysis - PUSH_NOTIFICATION_SECURITY.md: Push notification security guide - UI_UX_IMPROVEMENT_PLAN.md: Planned UI/UX enhancements - UI_UX_IMPROVEMENTS_COMPLETED.md: Completed improvements Cleanup: - Removed temporary database WAL files - Removed stale commit message file 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
108 lines
3.7 KiB
C#
108 lines
3.7 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using LittleShop.Services;
|
|
|
|
namespace LittleShop.Areas.Admin.Controllers;
|
|
|
|
[Area("Admin")]
|
|
[Authorize(AuthenticationSchemes = "Cookies", Roles = "Admin")]
|
|
public class PushSubscriptionsController : Controller
|
|
{
|
|
private readonly IPushNotificationService _pushService;
|
|
private readonly ILogger<PushSubscriptionsController> _logger;
|
|
|
|
public PushSubscriptionsController(
|
|
IPushNotificationService pushService,
|
|
ILogger<PushSubscriptionsController> logger)
|
|
{
|
|
_pushService = pushService;
|
|
_logger = logger;
|
|
}
|
|
|
|
// GET: Admin/PushSubscriptions
|
|
public async Task<IActionResult> Index()
|
|
{
|
|
try
|
|
{
|
|
var subscriptions = await _pushService.GetActiveSubscriptionsAsync();
|
|
return View(subscriptions.OrderByDescending(s => s.SubscribedAt));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Error retrieving push subscriptions list");
|
|
TempData["ErrorMessage"] = "Failed to load push subscriptions. Please try again.";
|
|
return View(new List<LittleShop.Models.PushSubscription>());
|
|
}
|
|
}
|
|
|
|
// POST: Admin/PushSubscriptions/Delete/{id}
|
|
[HttpPost]
|
|
[ValidateAntiForgeryToken]
|
|
public async Task<IActionResult> Delete(int id)
|
|
{
|
|
try
|
|
{
|
|
// Find subscription by ID and delete via UnsubscribeAsync (which uses endpoint)
|
|
var subscriptions = await _pushService.GetActiveSubscriptionsAsync();
|
|
var subscription = subscriptions.FirstOrDefault(s => s.Id == id);
|
|
|
|
if (subscription == null)
|
|
{
|
|
TempData["ErrorMessage"] = "Push subscription not found.";
|
|
return RedirectToAction(nameof(Index));
|
|
}
|
|
|
|
var success = await _pushService.UnsubscribeAsync(subscription.Endpoint);
|
|
|
|
if (success)
|
|
{
|
|
_logger.LogInformation("Deleted push subscription {Id} (Endpoint: {Endpoint})", id, subscription.Endpoint);
|
|
TempData["SuccessMessage"] = "Push subscription deleted successfully.";
|
|
}
|
|
else
|
|
{
|
|
_logger.LogWarning("Failed to delete push subscription {Id}", id);
|
|
TempData["ErrorMessage"] = "Failed to delete push subscription.";
|
|
}
|
|
|
|
return RedirectToAction(nameof(Index));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Error deleting push subscription {Id}", id);
|
|
TempData["ErrorMessage"] = $"Error deleting push subscription: {ex.Message}";
|
|
return RedirectToAction(nameof(Index));
|
|
}
|
|
}
|
|
|
|
// POST: Admin/PushSubscriptions/CleanupExpired
|
|
[HttpPost]
|
|
[ValidateAntiForgeryToken]
|
|
public async Task<IActionResult> CleanupExpired()
|
|
{
|
|
try
|
|
{
|
|
var deletedCount = await _pushService.CleanupExpiredSubscriptionsAsync();
|
|
|
|
_logger.LogInformation("Cleaned up {Count} expired push subscriptions", deletedCount);
|
|
|
|
if (deletedCount > 0)
|
|
{
|
|
TempData["SuccessMessage"] = $"Successfully cleaned up {deletedCount} expired subscription(s).";
|
|
}
|
|
else
|
|
{
|
|
TempData["InfoMessage"] = "No expired subscriptions found to clean up.";
|
|
}
|
|
|
|
return RedirectToAction(nameof(Index));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Error cleaning up expired push subscriptions");
|
|
TempData["ErrorMessage"] = $"Error during cleanup: {ex.Message}";
|
|
return RedirectToAction(nameof(Index));
|
|
}
|
|
}
|
|
}
|