- Created PublicBotsController with [AllowAnonymous] at class level to avoid policy authorization conflicts with the main BotsController - Updated ShareCard.cshtml to use PublicBots controller for embed links - Fixes HTTP 500 error when accessing ShareCard without authentication 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
67 lines
2.0 KiB
C#
67 lines
2.0 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using LittleShop.Services;
|
|
|
|
namespace LittleShop.Areas.Admin.Controllers;
|
|
|
|
/// <summary>
|
|
/// Public-facing bot pages that don't require authentication.
|
|
/// These are separated from the main BotsController to avoid authorization conflicts.
|
|
/// </summary>
|
|
[Area("Admin")]
|
|
[AllowAnonymous]
|
|
public class PublicBotsController : Controller
|
|
{
|
|
private readonly IBotService _botService;
|
|
|
|
public PublicBotsController(IBotService botService)
|
|
{
|
|
_botService = botService;
|
|
}
|
|
|
|
// GET: Admin/PublicBots/ShareCard/5
|
|
public async Task<IActionResult> ShareCard(Guid id)
|
|
{
|
|
var bot = await _botService.GetBotByIdAsync(id);
|
|
if (bot == null)
|
|
return NotFound();
|
|
|
|
// Build the tg.me link
|
|
var telegramLink = !string.IsNullOrEmpty(bot.PlatformUsername)
|
|
? $"https://t.me/{bot.PlatformUsername}"
|
|
: null;
|
|
|
|
ViewData["TelegramLink"] = telegramLink;
|
|
|
|
// Get review stats (TODO: Replace with actual review data from database)
|
|
// For now using sample data - in production, query from Reviews table
|
|
ViewData["ReviewCount"] = 127;
|
|
ViewData["AverageRating"] = 4.8m;
|
|
|
|
return View("~/Areas/Admin/Views/Bots/ShareCard.cshtml", bot);
|
|
}
|
|
|
|
// GET: Admin/PublicBots/ShareCardEmbed/5
|
|
public async Task<IActionResult> ShareCardEmbed(Guid id)
|
|
{
|
|
var bot = await _botService.GetBotByIdAsync(id);
|
|
if (bot == null)
|
|
return NotFound();
|
|
|
|
// Build the tg.me link
|
|
var telegramLink = !string.IsNullOrEmpty(bot.PlatformUsername)
|
|
? $"https://t.me/{bot.PlatformUsername}"
|
|
: null;
|
|
|
|
ViewData["TelegramLink"] = telegramLink;
|
|
|
|
// Get review stats
|
|
ViewData["ReviewCount"] = 127;
|
|
ViewData["AverageRating"] = 4.8m;
|
|
|
|
return View("~/Areas/Admin/Views/Bots/ShareCardEmbed.cshtml", bot);
|
|
}
|
|
}
|