Fix admin route access and backend configuration

- Added /admin redirect to login page in nginx config
- Fixed backend server.js route ordering for proper admin handling
- Updated authentication middleware and routes
- Added user management routes
- Configured PostgreSQL integration
- Updated environment configuration
This commit is contained in:
Local Server
2025-12-13 22:34:11 -06:00
parent 8bb6430a70
commit 703ab57984
253 changed files with 29870 additions and 157 deletions

45
Models/AdminUser.cs Normal file
View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace SkyArtShop.Models;
public class AdminUser
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; }
[Required]
[EmailAddress]
public string Email { get; set; } = string.Empty;
[Required]
public string PasswordHash { get; set; } = string.Empty;
[Required]
public string Name { get; set; } = string.Empty;
[Required]
public string Role { get; set; } = "Admin";
public List<string> Permissions { get; set; } = new List<string>();
public bool IsActive { get; set; } = true;
public bool PasswordNeverExpires { get; set; } = true;
public DateTime? PasswordExpiresAt { get; set; }
public string CreatedBy { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime? LastLogin { get; set; }
public string Phone { get; set; } = string.Empty;
public string Notes { get; set; } = string.Empty;
}

38
Models/BlogPost.cs Normal file
View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace SkyArtShop.Models;
public class BlogPost
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; }
[Required]
public string Title { get; set; } = string.Empty;
[Required]
public string Slug { get; set; } = string.Empty;
public string Content { get; set; } = string.Empty;
public string Excerpt { get; set; } = string.Empty;
public string FeaturedImage { get; set; } = string.Empty;
public string Author { get; set; } = string.Empty;
public List<string> Tags { get; set; } = new List<string>();
public bool IsPublished { get; set; } = true;
public DateTime PublishedDate { get; set; } = DateTime.UtcNow;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
}

10
Models/CollectionItem.cs Normal file
View File

@@ -0,0 +1,10 @@
namespace SkyArtShop.Models;
public class CollectionItem
{
public string Title { get; set; } = string.Empty;
public string ImageUrl { get; set; } = string.Empty;
public string Link { get; set; } = string.Empty;
}

37
Models/HomepageSection.cs Normal file
View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace SkyArtShop.Models;
public class HomepageSection
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; }
public string SectionType { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public string Subtitle { get; set; } = string.Empty;
public string Content { get; set; } = string.Empty;
public string ImageUrl { get; set; } = string.Empty;
public string ButtonText { get; set; } = string.Empty;
public string ButtonUrl { get; set; } = string.Empty;
public int DisplayOrder { get; set; }
public bool IsActive { get; set; } = true;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
public Dictionary<string, string> AdditionalData { get; set; } = new Dictionary<string, string>();
}

31
Models/MenuItem.cs Normal file
View File

@@ -0,0 +1,31 @@
using System;
using System.ComponentModel.DataAnnotations;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace SkyArtShop.Models;
public class MenuItem
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; }
[Required]
public string Label { get; set; } = string.Empty;
[Required]
public string Url { get; set; } = string.Empty;
public int DisplayOrder { get; set; }
public bool IsActive { get; set; } = true;
public bool ShowInNavbar { get; set; } = true;
public bool ShowInDropdown { get; set; } = true;
public bool OpenInNewTab { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}

27
Models/Order.cs Normal file
View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace SkyArtShop.Models;
public class Order
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; }
public string CustomerEmail { get; set; } = string.Empty;
public string CustomerName { get; set; } = string.Empty;
public List<OrderItem> Items { get; set; } = new List<OrderItem>();
public decimal TotalAmount { get; set; }
public string Status { get; set; } = "Pending";
public DateTime OrderDate { get; set; } = DateTime.UtcNow;
public DateTime? CompletedDate { get; set; }
}

16
Models/OrderItem.cs Normal file
View File

@@ -0,0 +1,16 @@
namespace SkyArtShop.Models;
public class OrderItem
{
public string ProductId { get; set; } = string.Empty;
public string ProductName { get; set; } = string.Empty;
public string SKU { get; set; } = string.Empty;
public int Quantity { get; set; }
public decimal Price { get; set; }
public decimal Subtotal { get; set; }
}

46
Models/Page.cs Normal file
View File

@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace SkyArtShop.Models;
public class Page
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string? Id { get; set; }
[Required]
public string PageName { get; set; } = string.Empty;
public string PageSlug { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public string Subtitle { get; set; } = string.Empty;
public string HeroImage { get; set; } = string.Empty;
public string Content { get; set; } = string.Empty;
public string MetaDescription { get; set; } = string.Empty;
public List<string> ImageGallery { get; set; } = new List<string>();
public string AboutImage1 { get; set; } = string.Empty;
public string AboutImage2 { get; set; } = string.Empty;
public List<TeamMember> TeamMembers { get; set; } = new List<TeamMember>();
public bool IsActive { get; set; } = true;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
}

View File

@@ -0,0 +1,33 @@
using System;
using System.ComponentModel.DataAnnotations;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace SkyArtShop.Models;
public class PortfolioCategory
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
[Required]
public string Slug { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string ThumbnailImage { get; set; } = string.Empty;
public string FeaturedImage { get; set; } = string.Empty;
public int DisplayOrder { get; set; }
public bool IsActive { get; set; } = true;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
}

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace SkyArtShop.Models;
public class PortfolioProject
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; }
[Required]
public string Title { get; set; } = string.Empty;
[Required]
public string CategoryId { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string FeaturedImage { get; set; } = string.Empty;
public List<string> Images { get; set; } = new List<string>();
public string ProjectDate { get; set; } = string.Empty;
public int DisplayOrder { get; set; }
public bool IsActive { get; set; } = true;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
}

66
Models/Product.cs Normal file
View File

@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace SkyArtShop.Models;
public class Product
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
public string Slug { get; set; } = string.Empty;
public string SKU { get; set; } = string.Empty;
public string ShortDescription { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
[Required]
public decimal Price { get; set; }
public string Category { get; set; } = string.Empty;
public string Color { get; set; } = string.Empty;
public List<string> Colors { get; set; } = new List<string>();
public List<ProductVariant> Variants { get; set; } = new List<ProductVariant>();
public string ImageUrl { get; set; } = string.Empty;
public List<string> Images { get; set; } = new List<string>();
public bool IsFeatured { get; set; }
public bool IsTopSeller { get; set; }
public int StockQuantity { get; set; }
public bool IsActive { get; set; } = true;
public int UnitsSold { get; set; }
public decimal TotalRevenue { get; set; }
public double AverageRating { get; set; }
public int TotalReviews { get; set; }
public decimal CostPrice { get; set; }
public List<string> Tags { get; set; } = new List<string>();
public string MetaDescription { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
}

20
Models/ProductVariant.cs Normal file
View File

@@ -0,0 +1,20 @@
using System.Collections.Generic;
namespace SkyArtShop.Models;
public class ProductVariant
{
public string ColorName { get; set; } = string.Empty;
public string ColorHex { get; set; } = string.Empty;
public List<string> Images { get; set; } = new List<string>();
public int StockQuantity { get; set; }
public decimal? PriceAdjustment { get; set; }
public bool IsAvailable { get; set; } = true;
public string SKU { get; set; } = string.Empty;
}

20
Models/ProductView.cs Normal file
View File

@@ -0,0 +1,20 @@
using System;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace SkyArtShop.Models;
public class ProductView
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; }
public string ProductId { get; set; } = string.Empty;
public string SessionId { get; set; } = string.Empty;
public string IpAddress { get; set; } = string.Empty;
public DateTime ViewedAt { get; set; } = DateTime.UtcNow;
}

14
Models/PromotionCard.cs Normal file
View File

@@ -0,0 +1,14 @@
namespace SkyArtShop.Models;
public class PromotionCard
{
public string Title { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string ButtonText { get; set; } = string.Empty;
public string ButtonUrl { get; set; } = string.Empty;
public bool IsFeatured { get; set; }
}

27
Models/SiteSettings.cs Normal file
View File

@@ -0,0 +1,27 @@
using System;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace SkyArtShop.Models;
[BsonIgnoreExtraElements]
public class SiteSettings
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; }
public string SiteName { get; set; } = "Sky Art Shop";
public string SiteTagline { get; set; } = "Scrapbooking and Journaling Fun";
public string ContactEmail { get; set; } = "info@skyartshop.com";
public string ContactPhone { get; set; } = "+501 608-0409";
public string InstagramUrl { get; set; } = "#";
public string FooterText { get; set; } = "© 2035 by Sky Art Shop. Powered and secured by Wix";
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
}

12
Models/TeamMember.cs Normal file
View File

@@ -0,0 +1,12 @@
namespace SkyArtShop.Models;
public class TeamMember
{
public string Name { get; set; } = string.Empty;
public string Role { get; set; } = string.Empty;
public string Bio { get; set; } = string.Empty;
public string PhotoUrl { get; set; } = string.Empty;
}

25
Models/UserRole.cs Normal file
View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace SkyArtShop.Models;
public class UserRole
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; }
[Required]
public string RoleName { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public List<string> Permissions { get; set; } = new List<string>();
public bool IsSystemRole { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}