🗑️ Remove built-in frontend serving code
This commit is contained in:
@@ -2,8 +2,8 @@ using System.Globalization;
|
||||
using System.Text.Json;
|
||||
using DysonNetwork.Pass.Auth;
|
||||
using DysonNetwork.Pass.Auth.OpenId;
|
||||
using DysonNetwork.Pass.Email;
|
||||
using DysonNetwork.Pass.Localization;
|
||||
using DysonNetwork.Pass.Mailer;
|
||||
using DysonNetwork.Pass.Permission;
|
||||
using DysonNetwork.Shared.Cache;
|
||||
using DysonNetwork.Shared.Data;
|
||||
@@ -452,7 +452,7 @@ public class AccountService(
|
||||
}
|
||||
|
||||
await mailer
|
||||
.SendTemplatedEmailAsync<Pages.Emails.VerificationEmail, VerificationEmailModel>(
|
||||
.SendTemplatedEmailAsync<Emails.VerificationEmail, VerificationEmailModel>(
|
||||
account.Nick,
|
||||
contact.Content,
|
||||
emailLocalizer["VerificationEmail"],
|
||||
|
@@ -1,7 +1,7 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.Json;
|
||||
using DysonNetwork.Pass.Email;
|
||||
using DysonNetwork.Pass.Pages.Emails;
|
||||
using DysonNetwork.Pass.Emails;
|
||||
using DysonNetwork.Pass.Mailer;
|
||||
using DysonNetwork.Pass.Permission;
|
||||
using DysonNetwork.Shared.Cache;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
@@ -135,14 +135,5 @@
|
||||
<LastGenOutput>SharedResource.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="Pages\Emails\AccountDeletionEmail.razor" />
|
||||
<AdditionalFiles Include="Pages\Emails\ContactVerificationEmail.razor" />
|
||||
<AdditionalFiles Include="Pages\Emails\EmailLayout.razor" />
|
||||
<AdditionalFiles Include="Pages\Emails\LandingEmail.razor" />
|
||||
<AdditionalFiles Include="Pages\Emails\PasswordResetEmail.razor" />
|
||||
<AdditionalFiles Include="Pages\Emails\VerificationEmail.razor" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace DysonNetwork.Pass.Email;
|
||||
namespace DysonNetwork.Pass.Mailer;
|
||||
|
||||
public class LandingEmailModel
|
||||
{
|
@@ -1,7 +1,7 @@
|
||||
using DysonNetwork.Shared.Proto;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace DysonNetwork.Pass.Email;
|
||||
namespace DysonNetwork.Pass.Mailer;
|
||||
|
||||
public class EmailService(
|
||||
RingService.RingServiceClient pusher,
|
@@ -1,15 +1,7 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Abstractions;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Microsoft.AspNetCore.Mvc.Razor;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
using RouteData = Microsoft.AspNetCore.Routing.RouteData;
|
||||
|
||||
namespace DysonNetwork.Pass.Email;
|
||||
namespace DysonNetwork.Pass.Mailer;
|
||||
|
||||
public class RazorViewRenderer(
|
||||
IServiceProvider serviceProvider,
|
@@ -1,52 +0,0 @@
|
||||
using System.Net;
|
||||
using DysonNetwork.Pass.Wallet;
|
||||
using DysonNetwork.Shared.PageData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenGraphNet;
|
||||
|
||||
namespace DysonNetwork.Pass.Pages.Data;
|
||||
|
||||
public class AccountPageData(AppDatabase db, SubscriptionService subscriptions, IConfiguration configuration)
|
||||
: IPageDataProvider
|
||||
{
|
||||
private readonly string _siteUrl = configuration["SiteUrl"]!;
|
||||
|
||||
public bool CanHandlePath(PathString path) =>
|
||||
path.StartsWithSegments("/accounts") || path.ToString().StartsWith("/@");
|
||||
|
||||
public async Task<IDictionary<string, object?>> GetAppDataAsync(HttpContext context)
|
||||
{
|
||||
var path = context.Request.Path.Value!;
|
||||
var startIndex = path.StartsWith("/accounts/") ? "/accounts/".Length : "/@".Length;
|
||||
var endIndex = path.IndexOf('/', startIndex);
|
||||
var username = endIndex == -1 ? path[startIndex..] : path.Substring(startIndex, endIndex - startIndex);
|
||||
username = WebUtility.UrlDecode(username);
|
||||
if (username.StartsWith("@"))
|
||||
username = username[1..];
|
||||
|
||||
var account = await db.Accounts
|
||||
.Include(e => e.Badges)
|
||||
.Include(e => e.Profile)
|
||||
.Where(a => a.Name == username)
|
||||
.FirstOrDefaultAsync();
|
||||
if (account is null) return new Dictionary<string, object?>();
|
||||
|
||||
var perk = await subscriptions.GetPerkSubscriptionAsync(account.Id);
|
||||
account.PerkSubscription = perk?.ToReference();
|
||||
|
||||
var og = OpenGraph.MakeGraph(
|
||||
title: account.Nick,
|
||||
type: "profile",
|
||||
image: $"{_siteUrl}/cgi/drive/files/{account.Profile.Picture?.Id}?original=true",
|
||||
url: $"{_siteUrl}/@{username}",
|
||||
description: account.Profile.Bio ?? $"@{account.Name} profile on the Solar Network",
|
||||
siteName: "Solarpass"
|
||||
);
|
||||
|
||||
return new Dictionary<string, object?>()
|
||||
{
|
||||
["Account"] = account,
|
||||
["OpenGraph"] = og
|
||||
};
|
||||
}
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
using DysonNetwork.Shared.PageData;
|
||||
|
||||
namespace DysonNetwork.Pass.Pages.Data;
|
||||
|
||||
public class CaptchaPageData(IConfiguration configuration) : IPageDataProvider
|
||||
{
|
||||
public bool CanHandlePath(PathString path) => path == "/captcha";
|
||||
|
||||
public Task<IDictionary<string, object?>> GetAppDataAsync(HttpContext context)
|
||||
{
|
||||
var provider = configuration.GetSection("Captcha")["Provider"]?.ToLower();
|
||||
var apiKey = configuration.GetSection("Captcha")["ApiKey"];
|
||||
|
||||
return Task.FromResult<IDictionary<string, object?>>(new Dictionary<string, object?>
|
||||
{
|
||||
["Provider"] = provider,
|
||||
["ApiKey"] = apiKey
|
||||
});
|
||||
}
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
using DysonNetwork.Shared.Data;
|
||||
using DysonNetwork.Shared.PageData;
|
||||
|
||||
namespace DysonNetwork.Pass.Pages.Data;
|
||||
|
||||
public class VersionPageData : IPageDataProvider
|
||||
{
|
||||
public bool CanHandlePath(PathString path) => true;
|
||||
|
||||
public Task<IDictionary<string, object?>> GetAppDataAsync(HttpContext context)
|
||||
{
|
||||
var versionData = new AppVersion
|
||||
{
|
||||
Version = ThisAssembly.AssemblyVersion,
|
||||
Commit = ThisAssembly.GitCommitId,
|
||||
UpdateDate = ThisAssembly.GitCommitDate
|
||||
};
|
||||
|
||||
var result = typeof(AppVersion).GetProperties()
|
||||
.ToDictionary(property => property.Name, property => property.GetValue(versionData));
|
||||
|
||||
return Task.FromResult<IDictionary<string, object?>>(result);
|
||||
}
|
||||
}
|
@@ -1,8 +1,6 @@
|
||||
using DysonNetwork.Pass;
|
||||
using DysonNetwork.Pass.Pages.Data;
|
||||
using DysonNetwork.Pass.Startup;
|
||||
using DysonNetwork.Shared.Http;
|
||||
using DysonNetwork.Shared.PageData;
|
||||
using DysonNetwork.Shared.Registry;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
@@ -31,10 +29,6 @@ builder.Services.AddAppBusinessServices(builder.Configuration);
|
||||
// Add scheduled jobs
|
||||
builder.Services.AddAppScheduledJobs();
|
||||
|
||||
builder.Services.AddTransient<IPageDataProvider, VersionPageData>();
|
||||
builder.Services.AddTransient<IPageDataProvider, CaptchaPageData>();
|
||||
builder.Services.AddTransient<IPageDataProvider, AccountPageData>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.MapDefaultEndpoints();
|
||||
@@ -47,9 +41,7 @@ using (var scope = app.Services.CreateScope())
|
||||
}
|
||||
|
||||
// Configure application middleware pipeline
|
||||
app.ConfigureAppMiddleware(builder.Configuration, builder.Environment.ContentRootPath);
|
||||
|
||||
app.MapPages(Path.Combine(builder.Environment.WebRootPath, "dist", "index.html"));
|
||||
app.ConfigureAppMiddleware(builder.Configuration);
|
||||
|
||||
// Configure gRPC
|
||||
app.ConfigureGrpcServices();
|
||||
|
@@ -14,7 +14,7 @@ namespace DysonNetwork.Pass.Startup;
|
||||
|
||||
public static class ApplicationConfiguration
|
||||
{
|
||||
public static WebApplication ConfigureAppMiddleware(this WebApplication app, IConfiguration configuration, string contentRoot)
|
||||
public static WebApplication ConfigureAppMiddleware(this WebApplication app, IConfiguration configuration)
|
||||
{
|
||||
app.MapMetrics();
|
||||
app.MapOpenApi();
|
||||
@@ -41,12 +41,6 @@ public static class ApplicationConfiguration
|
||||
app.UseAuthorization();
|
||||
app.UseMiddleware<PermissionMiddleware>();
|
||||
|
||||
app.UseDefaultFiles();
|
||||
app.UseStaticFiles(new StaticFileOptions
|
||||
{
|
||||
FileProvider = new PhysicalFileProvider(Path.Combine(contentRoot, "wwwroot", "dist"))
|
||||
});
|
||||
|
||||
app.MapControllers().RequireRateLimiting("fixed");
|
||||
|
||||
return app;
|
||||
|
@@ -2,7 +2,6 @@ using System.Globalization;
|
||||
using DysonNetwork.Pass.Account;
|
||||
using DysonNetwork.Pass.Auth;
|
||||
using DysonNetwork.Pass.Auth.OpenId;
|
||||
using DysonNetwork.Pass.Email;
|
||||
using DysonNetwork.Pass.Localization;
|
||||
using DysonNetwork.Pass.Permission;
|
||||
using DysonNetwork.Pass.Wallet;
|
||||
@@ -19,6 +18,7 @@ using DysonNetwork.Pass.Auth.OidcProvider.Services;
|
||||
using DysonNetwork.Pass.Credit;
|
||||
using DysonNetwork.Pass.Handlers;
|
||||
using DysonNetwork.Pass.Leveling;
|
||||
using DysonNetwork.Pass.Mailer;
|
||||
using DysonNetwork.Pass.Safety;
|
||||
using DysonNetwork.Pass.Wallet.PaymentHandlers;
|
||||
using DysonNetwork.Shared.Cache;
|
||||
|
Reference in New Issue
Block a user