Done some todo's and removed old TL tags
This commit is contained in:
parent
7145890801
commit
3a53fa0a3c
11 changed files with 60 additions and 17 deletions
|
@ -32,6 +32,10 @@ public class ConfigV1
|
|||
[JsonProperty("EnableEmailVerify")]
|
||||
[Description("This will users force to verify their email address if they havent already")]
|
||||
public bool EnableEmailVerify { get; set; } = false;
|
||||
|
||||
[JsonProperty("EnableReverseProxyMode")]
|
||||
[Description("Enable this option if you are using a reverse proxy to access moonlight. This will configure some parts of moonlight to act correctly like the ip detection")]
|
||||
public bool EnableReverseProxyMode { get; set; } = false;
|
||||
}
|
||||
|
||||
public class DatabaseData
|
||||
|
@ -69,5 +73,9 @@ public class ConfigV1
|
|||
[JsonProperty("Password")] public string Password { get; set; } = "s3cr3t";
|
||||
|
||||
[JsonProperty("UseSsl")] public bool UseSsl { get; set; } = true;
|
||||
|
||||
[JsonProperty("SenderName")]
|
||||
[Description("This will be shown as the system emails sender name in apps like gmail")]
|
||||
public string SenderName { get; set; } = "Moonlight System";
|
||||
}
|
||||
}
|
|
@ -116,8 +116,6 @@ public class PostService
|
|||
if(await CheckTextForBadWords(content))
|
||||
throw new DisplayException("Bad word detected. Please follow the community rules");
|
||||
|
||||
//TODO: Swear word filter
|
||||
|
||||
var comment = new PostComment()
|
||||
{
|
||||
Author = user,
|
||||
|
|
|
@ -28,7 +28,7 @@ public class MailService
|
|||
var message = new MimeMessage();
|
||||
|
||||
message.From.Add(new MailboxAddress(
|
||||
"Moonlight System", //TODO: Replace with config option
|
||||
config.SenderName,
|
||||
config.Email
|
||||
));
|
||||
|
||||
|
|
|
@ -11,16 +11,19 @@ public class StoreAdminService
|
|||
{
|
||||
private readonly Repository<Product> ProductRepository;
|
||||
private readonly Repository<Category> CategoryRepository;
|
||||
private readonly Repository<Service> ServiceRepository;
|
||||
private readonly ServiceService ServiceService;
|
||||
|
||||
public StoreAdminService(
|
||||
Repository<Product> productRepository,
|
||||
Repository<Category> categoryRepository,
|
||||
ServiceService serviceService)
|
||||
ServiceService serviceService,
|
||||
Repository<Service> serviceRepository)
|
||||
{
|
||||
ProductRepository = productRepository;
|
||||
CategoryRepository = categoryRepository;
|
||||
ServiceService = serviceService;
|
||||
ServiceRepository = serviceRepository;
|
||||
}
|
||||
|
||||
public Task<Category> AddCategory(string name, string description, string slug)
|
||||
|
@ -96,7 +99,8 @@ public class StoreAdminService
|
|||
|
||||
public Task DeleteProduct(Product product)
|
||||
{
|
||||
//TODO: Implement checks if services with that product id exist
|
||||
if (ServiceRepository.Get().Any(x => x.Product.Id == product.Id))
|
||||
throw new DisplayException("Product cannot be deleted as services related to this products exist. Delete the services first");
|
||||
|
||||
ProductRepository.Delete(product);
|
||||
|
||||
|
|
34
Moonlight/App/Services/Utils/ConnectionService.cs
Normal file
34
Moonlight/App/Services/Utils/ConnectionService.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using Moonlight.App.Helpers;
|
||||
|
||||
namespace Moonlight.App.Services.Utils;
|
||||
|
||||
public class ConnectionService
|
||||
{
|
||||
private readonly IHttpContextAccessor ContextAccessor;
|
||||
private readonly ConfigService ConfigService;
|
||||
|
||||
public ConnectionService(IHttpContextAccessor contextAccessor, ConfigService configService)
|
||||
{
|
||||
ContextAccessor = contextAccessor;
|
||||
ConfigService = configService;
|
||||
}
|
||||
|
||||
public Task<string> GetIpAddress()
|
||||
{
|
||||
if (ContextAccessor.HttpContext == null)
|
||||
return Task.FromResult("N/A (Missing http context)");
|
||||
|
||||
var request = ContextAccessor.HttpContext.Request;
|
||||
|
||||
if (request.Headers.ContainsKey("X-Real-IP"))
|
||||
{
|
||||
if(ConfigService.Get().Security.EnableReverseProxyMode)
|
||||
return Task.FromResult(request.Headers["X-Real-IP"].ToString());
|
||||
|
||||
Logger.Warn($"Detected an ip mask attempt by using a fake X-Real-IP header. Fake IP: {request.Headers["X-Real-IP"]}. Real IP: {ContextAccessor.HttpContext.Connection.RemoteIpAddress}");
|
||||
return Task.FromResult(ContextAccessor.HttpContext.Connection.RemoteIpAddress?.ToString() ?? "N/A (Remote IP missing)");
|
||||
}
|
||||
|
||||
return Task.FromResult(ContextAccessor.HttpContext.Connection.RemoteIpAddress?.ToString() ?? "N/A (Remote IP missing)");
|
||||
}
|
||||
}
|
|
@ -50,6 +50,7 @@ builder.Services.AddScoped(typeof(Repository<>));
|
|||
|
||||
// Services / Utils
|
||||
builder.Services.AddScoped<JwtService>();
|
||||
builder.Services.AddScoped<ConnectionService>();
|
||||
|
||||
// Services / Interop
|
||||
builder.Services.AddScoped<CookieService>();
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<div class="alert alert-danger bg-danger text-white p-10 mb-3">
|
||||
@foreach (var msg in ErrorMessages)
|
||||
{
|
||||
<TL>@(msg)</TL>
|
||||
@(msg)
|
||||
<br/>
|
||||
}
|
||||
</div>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
@if (Crashed)
|
||||
{
|
||||
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development" || IdentityService.Permissions[Permission.AdminViewExceptions]) // TODO: Add check for admin perms to show exceptions to admins
|
||||
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == "Development" || IdentityService.Permissions[Permission.AdminViewExceptions])
|
||||
{
|
||||
if (Exception != null)
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
@using Moonlight.App.Models.Enums
|
||||
@using Moonlight.Shared.Components.Auth
|
||||
@using Moonlight.App.Event
|
||||
@using Moonlight.App.Services.Utils
|
||||
|
||||
@inherits LayoutComponentBase
|
||||
@implements IDisposable
|
||||
|
@ -12,7 +13,7 @@
|
|||
@inject IdentityService IdentityService
|
||||
@inject SessionService SessionService
|
||||
@inject NavigationManager Navigation
|
||||
@inject IJSRuntime JsRuntime
|
||||
@inject ConnectionService ConnectionService
|
||||
|
||||
@{
|
||||
var url = new Uri(Navigation.Uri);
|
||||
|
@ -140,7 +141,7 @@ else
|
|||
|
||||
MySession = new()
|
||||
{
|
||||
//Ip = ConnectionService.GetIp(), TODO: Implement
|
||||
Ip = await ConnectionService.GetIpAddress(),
|
||||
Url = Navigation.Uri,
|
||||
User = IdentityService.CurrentUserNullable
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<div class="row align-items-center gx-0">
|
||||
<div class="col">
|
||||
<h6 class="text-uppercase text-muted mb-2">
|
||||
<TL>Total Tickets</TL>
|
||||
Total Tickets
|
||||
</h6>
|
||||
<span class="h2 mb-0">
|
||||
@(TotalTicketsCount)
|
||||
|
@ -45,7 +45,7 @@
|
|||
<div class="row align-items-center gx-0">
|
||||
<div class="col">
|
||||
<h6 class="text-uppercase text-muted mb-2">
|
||||
<TL>Pending tickets</TL>
|
||||
Pending tickets
|
||||
</h6>
|
||||
<span class="h2 mb-0">
|
||||
@(PendingTicketsCount)
|
||||
|
@ -66,7 +66,7 @@
|
|||
<div class="row align-items-center gx-0">
|
||||
<div class="col">
|
||||
<h6 class="text-uppercase text-muted mb-2">
|
||||
<TL>Closed tickets</TL>
|
||||
Closed tickets
|
||||
</h6>
|
||||
<span class="h2 mb-0">
|
||||
@(ClosedTicketsCount)
|
||||
|
@ -87,7 +87,7 @@
|
|||
<div class="card">
|
||||
<div class="card-header">
|
||||
<span class="card-title">
|
||||
<TL>Ticket overview</TL>
|
||||
Ticket overview
|
||||
</span>
|
||||
<div class="card-toolbar">
|
||||
<div class="btn-group">
|
||||
|
|
|
@ -11,16 +11,13 @@
|
|||
@inject IdentityService IdentityService
|
||||
@inject AlertService AlertService
|
||||
@inject NavigationManager Navigation
|
||||
@inject ServiceService ServiceService
|
||||
@inject Repository<Product> ProductRepository
|
||||
@inject Repository<Coupon> CouponRepository
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
@if (SelectedProduct == null)
|
||||
{
|
||||
@*
|
||||
TODO: Add 404 here
|
||||
*@
|
||||
<NotFoundAlert />
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue