mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-12 21:02:27 +00:00
Refactor Database class (#616)
Refactor Database into DatabaseContext Moved into separate folder so it actually has a namespace instead sitting in the root
This commit is contained in:
parent
2aff26f83d
commit
64b95e807d
246 changed files with 1211 additions and 965 deletions
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.API.Responses;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -12,9 +13,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.API.Controllers;
|
|||
/// </summary>
|
||||
public class SlotEndpoints : ApiEndpointController
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public SlotEndpoints(Database database)
|
||||
public SlotEndpoints(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Servers.API.Responses;
|
||||
using LBPUnion.ProjectLighthouse.Types.Users;
|
||||
|
@ -11,9 +12,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.API.Controllers;
|
|||
public class StatisticsEndpoints : ApiEndpointController
|
||||
{
|
||||
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public StatisticsEndpoints(Database database)
|
||||
public StatisticsEndpoints(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
|
@ -13,9 +14,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.API.Controllers;
|
|||
/// </summary>
|
||||
public class UserEndpoints : ApiEndpointController
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public UserEndpoints(Database database)
|
||||
public UserEndpoints(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Middlewares;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
@ -25,7 +26,7 @@ public class ApiStartup
|
|||
}
|
||||
);
|
||||
|
||||
services.AddDbContext<Database>();
|
||||
services.AddDbContext<DatabaseContext>();
|
||||
|
||||
services.AddSwaggerGen
|
||||
(
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#nullable enable
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -17,9 +18,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
|
|||
[Produces("text/plain")]
|
||||
public class ClientConfigurationController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public ClientConfigurationController(Database database)
|
||||
public ClientConfigurationController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
|
@ -18,8 +19,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
|
|||
[Produces("text/xml")]
|
||||
public class CommentController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
public CommentController(Database database)
|
||||
private readonly DatabaseContext database;
|
||||
public CommentController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
|
@ -18,9 +19,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
|
|||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
public class FriendsController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public FriendsController(Database database)
|
||||
public FriendsController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#nullable enable
|
||||
using System.Net;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
|
@ -19,9 +20,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
|
|||
[Produces("text/xml")]
|
||||
public class LoginController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public LoginController(Database database)
|
||||
public LoginController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
|
@ -14,9 +15,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
|
|||
public class LogoutController : ControllerBase
|
||||
{
|
||||
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public LogoutController(Database database)
|
||||
public LogoutController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
|
||||
|
@ -17,9 +18,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Matching;
|
|||
[Produces("text/xml")]
|
||||
public class EnterLevelController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public EnterLevelController(Database database)
|
||||
public EnterLevelController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using System.Text.Json;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
|
@ -21,9 +22,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Matching;
|
|||
[Produces("text/xml")]
|
||||
public class MatchController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public MatchController(Database database)
|
||||
public MatchController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
|
@ -18,7 +19,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
|
|||
[Produces("text/plain")]
|
||||
public class MessageController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
private const string license = @"
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
@ -34,7 +35,7 @@ GNU Affero General Public License for more details.
|
|||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.";
|
||||
|
||||
public MessageController(Database database)
|
||||
public MessageController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#nullable enable
|
||||
using System.Text.Json;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
|
||||
|
@ -17,9 +18,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
|
|||
[Produces("text/xml")]
|
||||
public class ReportController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public ReportController(Database database)
|
||||
public ReportController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#nullable enable
|
||||
using Discord;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Files;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
@ -23,9 +24,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Resources;
|
|||
[Produces("text/xml")]
|
||||
public class PhotosController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public PhotosController(Database database)
|
||||
public PhotosController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
|
@ -21,9 +22,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
|
|||
[Produces("text/xml")]
|
||||
public class CollectionController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public CollectionController(Database database)
|
||||
public CollectionController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
|
||||
|
@ -17,9 +18,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
|
|||
[Produces("text/plain")]
|
||||
public class LevelTagsController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public LevelTagsController(Database database)
|
||||
public LevelTagsController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
|
@ -20,8 +21,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
|
|||
[Produces("text/xml")]
|
||||
public class ListController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
public ListController(Database database)
|
||||
private readonly DatabaseContext database;
|
||||
public ListController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Files;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
@ -24,9 +25,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
|
|||
[Produces("text/xml")]
|
||||
public class PublishController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public PublishController(Database database)
|
||||
public PublishController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
|
@ -18,9 +19,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
|
|||
[Produces("text/xml")]
|
||||
public class ReviewController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public ReviewController(Database database)
|
||||
public ReviewController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
|
@ -22,9 +23,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
|
|||
[Produces("text/xml")]
|
||||
public class ScoreController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public ScoreController(Database database)
|
||||
public ScoreController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
|
@ -16,8 +17,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
|
|||
[Produces("text/xml")]
|
||||
public class SearchController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
public SearchController(Database database)
|
||||
private readonly DatabaseContext database;
|
||||
public SearchController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
|
@ -21,8 +22,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
|
|||
[Produces("text/xml")]
|
||||
public class SlotsController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
public SlotsController(Database database)
|
||||
private readonly DatabaseContext database;
|
||||
public SlotsController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
@ -13,9 +14,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
|
|||
public class StatisticsController : ControllerBase
|
||||
{
|
||||
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public StatisticsController(Database database)
|
||||
public StatisticsController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using System.Text.Json;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Files;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
|
@ -23,9 +24,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
|
|||
[Produces("text/xml")]
|
||||
public class UserController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public UserController(Database database)
|
||||
public UserController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Middlewares;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
|
@ -10,7 +11,7 @@ public class SetLastContactMiddleware : MiddlewareDBContext
|
|||
public SetLastContactMiddleware(RequestDelegate next) : base(next)
|
||||
{ }
|
||||
|
||||
public override async Task InvokeAsync(HttpContext context, Database database)
|
||||
public override async Task InvokeAsync(HttpContext context, DatabaseContext database)
|
||||
{
|
||||
#nullable enable
|
||||
// Log LastContact for LBP1. This is done on LBP2/3/V on a Match request.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Middlewares;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
|
@ -45,7 +46,7 @@ public class GameServerStartup
|
|||
}
|
||||
);
|
||||
|
||||
services.AddDbContext<Database>();
|
||||
services.AddDbContext<DatabaseContext>();
|
||||
|
||||
services.Configure<ForwardedHeadersOptions>
|
||||
(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System.Security.Claims;
|
||||
using System.Text.Encodings.Web;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
|
@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Startup;
|
|||
|
||||
public class TokenAuthHandler : AuthenticationHandler<AuthenticationSchemeOptions>
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
private const string cookie = "MM_AUTH";
|
||||
|
||||
public TokenAuthHandler
|
||||
|
@ -17,7 +18,7 @@ public class TokenAuthHandler : AuthenticationHandler<AuthenticationSchemeOption
|
|||
IOptionsMonitor<AuthenticationSchemeOptions> options,
|
||||
UrlEncoder encoder,
|
||||
ISystemClock clock,
|
||||
Database database
|
||||
DatabaseContext database
|
||||
// I said I don't want any damn vegetables (logs)
|
||||
) : base(options, new NullLoggerFactory(), encoder, clock)
|
||||
{
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
|
||||
|
@ -18,7 +19,7 @@ public static class CategoryHelper
|
|||
Categories.Add(new HeartedCategory());
|
||||
Categories.Add(new LuckyDipCategory());
|
||||
|
||||
using Database database = new();
|
||||
using DatabaseContext database = new();
|
||||
foreach (DatabaseCategory category in database.CustomCategories) Categories.Add(new CustomCategory(category));
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using System.Diagnostics;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
|
@ -11,8 +12,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Types.Categories;
|
|||
|
||||
public abstract class CategoryWithUser : Category
|
||||
{
|
||||
public abstract Slot? GetPreviewSlot(Database database, User user);
|
||||
public override Slot? GetPreviewSlot(Database database)
|
||||
public abstract Slot? GetPreviewSlot(DatabaseContext database, User user);
|
||||
public override Slot? GetPreviewSlot(DatabaseContext database)
|
||||
{
|
||||
#if DEBUG
|
||||
Logger.Error("tried to get preview slot without user on CategoryWithUser", LogArea.Category);
|
||||
|
@ -21,8 +22,8 @@ public abstract class CategoryWithUser : Category
|
|||
return null;
|
||||
}
|
||||
|
||||
public abstract int GetTotalSlots(Database database, User user);
|
||||
public override int GetTotalSlots(Database database)
|
||||
public abstract int GetTotalSlots(DatabaseContext database, User user);
|
||||
public override int GetTotalSlots(DatabaseContext database)
|
||||
{
|
||||
#if DEBUG
|
||||
Logger.Error("tried to get total slots without user on CategoryWithUser", LogArea.Category);
|
||||
|
@ -31,8 +32,8 @@ public abstract class CategoryWithUser : Category
|
|||
return -1;
|
||||
}
|
||||
|
||||
public abstract IEnumerable<Slot> GetSlots(Database database, User user, int pageStart, int pageSize);
|
||||
public override IEnumerable<Slot> GetSlots(Database database, int pageStart, int pageSize)
|
||||
public abstract IEnumerable<Slot> GetSlots(DatabaseContext database, User user, int pageStart, int pageSize);
|
||||
public override IEnumerable<Slot> GetSlots(DatabaseContext database, int pageStart, int pageSize)
|
||||
{
|
||||
#if DEBUG
|
||||
Logger.Error("tried to get slots without user on CategoryWithUser", LogArea.Category);
|
||||
|
@ -41,13 +42,13 @@ public abstract class CategoryWithUser : Category
|
|||
return new List<Slot>();
|
||||
}
|
||||
|
||||
public new string Serialize(Database database)
|
||||
public new string Serialize(DatabaseContext database)
|
||||
{
|
||||
Logger.Error("tried to serialize without user on CategoryWithUser", LogArea.Category);
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public string Serialize(Database database, User user)
|
||||
public string Serialize(DatabaseContext database, User user)
|
||||
{
|
||||
Slot? previewSlot = this.GetPreviewSlot(database, user);
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
|
@ -34,9 +35,9 @@ public class CustomCategory : Category
|
|||
public sealed override string Description { get; set; }
|
||||
public sealed override string IconHash { get; set; }
|
||||
public sealed override string Endpoint { get; set; }
|
||||
public override Slot? GetPreviewSlot(Database database) => database.Slots.FirstOrDefault(s => s.SlotId == this.SlotIds[0]);
|
||||
public override Slot? GetPreviewSlot(DatabaseContext database) => database.Slots.FirstOrDefault(s => s.SlotId == this.SlotIds[0]);
|
||||
public override IEnumerable<Slot> GetSlots
|
||||
(Database database, int pageStart, int pageSize)
|
||||
(DatabaseContext database, int pageStart, int pageSize)
|
||||
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3).Where(s => this.SlotIds.Contains(s.SlotId));
|
||||
public override int GetTotalSlots(Database database) => this.SlotIds.Count;
|
||||
public override int GetTotalSlots(DatabaseContext database) => this.SlotIds.Count;
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -14,7 +15,7 @@ public class HeartedCategory : CategoryWithUser
|
|||
public override string Description { get; set; } = "Content you've hearted";
|
||||
public override string IconHash { get; set; } = "g820611";
|
||||
public override string Endpoint { get; set; } = "hearted";
|
||||
public override Slot? GetPreviewSlot(Database database, User user) // note: developer slots act up in LBP3 when listed here, so I omitted it
|
||||
public override Slot? GetPreviewSlot(DatabaseContext database, User user) // note: developer slots act up in LBP3 when listed here, so I omitted it
|
||||
=> database.HeartedLevels.Where(h => h.UserId == user.UserId)
|
||||
.Where(h => h.Slot.Type == SlotType.User && !h.Slot.Hidden && h.Slot.GameVersion <= GameVersion.LittleBigPlanet3)
|
||||
.OrderByDescending(h => h.HeartedLevelId)
|
||||
|
@ -24,7 +25,7 @@ public class HeartedCategory : CategoryWithUser
|
|||
.ByGameVersion(GameVersion.LittleBigPlanet3, false, false, true)
|
||||
.FirstOrDefault();
|
||||
|
||||
public override IEnumerable<Slot> GetSlots(Database database, User user, int pageStart, int pageSize)
|
||||
public override IEnumerable<Slot> GetSlots(DatabaseContext database, User user, int pageStart, int pageSize)
|
||||
=> database.HeartedLevels.Where(h => h.UserId == user.UserId)
|
||||
.Where(h => h.Slot.Type == SlotType.User && !h.Slot.Hidden && h.Slot.GameVersion <= GameVersion.LittleBigPlanet3)
|
||||
.OrderByDescending(h => h.HeartedLevelId)
|
||||
|
@ -35,5 +36,5 @@ public class HeartedCategory : CategoryWithUser
|
|||
.Skip(Math.Max(0, pageStart))
|
||||
.Take(Math.Min(pageSize, 20));
|
||||
|
||||
public override int GetTotalSlots(Database database, User user) => database.HeartedLevels.Count(h => h.UserId == user.UserId);
|
||||
public override int GetTotalSlots(DatabaseContext database, User user) => database.HeartedLevels.Count(h => h.UserId == user.UserId);
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using System.Security.Cryptography;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
|
@ -13,14 +14,14 @@ public class HighestRatedCategory : Category
|
|||
public override string Description { get; set; } = "Community Highest Rated content";
|
||||
public override string IconHash { get; set; } = "g820603";
|
||||
public override string Endpoint { get; set; } = "thumbs";
|
||||
public override Slot? GetPreviewSlot(Database database) => database.Slots.Where(s => s.Type == SlotType.User).AsEnumerable().MaxBy(s => s.Thumbsup);
|
||||
public override Slot? GetPreviewSlot(DatabaseContext database) => database.Slots.Where(s => s.Type == SlotType.User).AsEnumerable().MaxBy(s => s.Thumbsup);
|
||||
public override IEnumerable<Slot> GetSlots
|
||||
(Database database, int pageStart, int pageSize)
|
||||
(DatabaseContext database, int pageStart, int pageSize)
|
||||
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true)
|
||||
.AsEnumerable()
|
||||
.OrderByDescending(s => s.Thumbsup)
|
||||
.ThenBy(_ => RandomNumberGenerator.GetInt32(int.MaxValue))
|
||||
.Skip(Math.Max(0, pageStart - 1))
|
||||
.Take(Math.Min(pageSize, 20));
|
||||
public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.Type == SlotType.User);
|
||||
public override int GetTotalSlots(DatabaseContext database) => database.Slots.Count(s => s.Type == SlotType.User);
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
|
@ -13,12 +14,12 @@ public class LuckyDipCategory : Category
|
|||
public override string Description { get; set; } = "Randomized uploaded content";
|
||||
public override string IconHash { get; set; } = "g820605";
|
||||
public override string Endpoint { get; set; } = "lbp2luckydip";
|
||||
public override Slot? GetPreviewSlot(Database database) => database.Slots.Where(s => s.Type == SlotType.User).OrderByDescending(_ => EF.Functions.Random()).FirstOrDefault();
|
||||
public override Slot? GetPreviewSlot(DatabaseContext database) => database.Slots.Where(s => s.Type == SlotType.User).OrderByDescending(_ => EF.Functions.Random()).FirstOrDefault();
|
||||
public override IEnumerable<Slot> GetSlots
|
||||
(Database database, int pageStart, int pageSize)
|
||||
(DatabaseContext database, int pageStart, int pageSize)
|
||||
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true)
|
||||
.OrderByDescending(_ => EF.Functions.Random())
|
||||
.Skip(Math.Max(0, pageStart - 1))
|
||||
.Take(Math.Min(pageSize, 20));
|
||||
public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.Type == SlotType.User);
|
||||
public override int GetTotalSlots(DatabaseContext database) => database.Slots.Count(s => s.Type == SlotType.User);
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using System.Security.Cryptography;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
|
@ -13,14 +14,14 @@ public class MostHeartedCategory : Category
|
|||
public override string Description { get; set; } = "The Most Hearted Content";
|
||||
public override string IconHash { get; set; } = "g820607";
|
||||
public override string Endpoint { get; set; } = "mostHearted";
|
||||
public override Slot? GetPreviewSlot(Database database) => database.Slots.Where(s => s.Type == SlotType.User).AsEnumerable().MaxBy(s => s.Hearts);
|
||||
public override Slot? GetPreviewSlot(DatabaseContext database) => database.Slots.Where(s => s.Type == SlotType.User).AsEnumerable().MaxBy(s => s.Hearts);
|
||||
public override IEnumerable<Slot> GetSlots
|
||||
(Database database, int pageStart, int pageSize)
|
||||
(DatabaseContext database, int pageStart, int pageSize)
|
||||
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true)
|
||||
.AsEnumerable()
|
||||
.OrderByDescending(s => s.Hearts)
|
||||
.ThenBy(_ => RandomNumberGenerator.GetInt32(int.MaxValue))
|
||||
.Skip(Math.Max(0, pageStart - 1))
|
||||
.Take(Math.Min(pageSize, 20));
|
||||
public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.Type == SlotType.User);
|
||||
public override int GetTotalSlots(DatabaseContext database) => database.Slots.Count(s => s.Type == SlotType.User);
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
|
@ -12,17 +13,17 @@ public class MostPlayedCategory : Category
|
|||
public override string Description { get; set; } = "The most played content";
|
||||
public override string IconHash { get; set; } = "g820608";
|
||||
public override string Endpoint { get; set; } = "mostUniquePlays";
|
||||
public override Slot? GetPreviewSlot(Database database) => database.Slots
|
||||
public override Slot? GetPreviewSlot(DatabaseContext database) => database.Slots
|
||||
.Where(s => s.Type == SlotType.User)
|
||||
.OrderByDescending(s => s.PlaysLBP1Unique + s.PlaysLBP2Unique + s.PlaysLBP3Unique)
|
||||
.ThenByDescending(s => s.PlaysLBP1 + s.PlaysLBP2 + s.PlaysLBP3)
|
||||
.FirstOrDefault();
|
||||
public override IEnumerable<Slot> GetSlots
|
||||
(Database database, int pageStart, int pageSize)
|
||||
(DatabaseContext database, int pageStart, int pageSize)
|
||||
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true)
|
||||
.OrderByDescending(s => s.PlaysLBP1Unique + s.PlaysLBP2Unique + s.PlaysLBP3Unique)
|
||||
.ThenByDescending(s => s.PlaysLBP1 + s.PlaysLBP2 + s.PlaysLBP3)
|
||||
.Skip(Math.Max(0, pageStart - 1))
|
||||
.Take(Math.Min(pageSize, 20));
|
||||
public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.Type == SlotType.User);
|
||||
public override int GetTotalSlots(DatabaseContext database) => database.Slots.Count(s => s.Type == SlotType.User);
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
|
@ -12,12 +13,12 @@ public class NewestLevelsCategory : Category
|
|||
public override string Description { get; set; } = "The most recently published content";
|
||||
public override string IconHash { get; set; } = "g820623";
|
||||
public override string Endpoint { get; set; } = "newest";
|
||||
public override Slot? GetPreviewSlot(Database database) => database.Slots.Where(s => s.Type == SlotType.User).OrderByDescending(s => s.FirstUploaded).FirstOrDefault();
|
||||
public override Slot? GetPreviewSlot(DatabaseContext database) => database.Slots.Where(s => s.Type == SlotType.User).OrderByDescending(s => s.FirstUploaded).FirstOrDefault();
|
||||
public override IEnumerable<Slot> GetSlots
|
||||
(Database database, int pageStart, int pageSize)
|
||||
(DatabaseContext database, int pageStart, int pageSize)
|
||||
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true)
|
||||
.OrderByDescending(s => s.FirstUploaded)
|
||||
.Skip(Math.Max(0, pageStart - 1))
|
||||
.Take(Math.Min(pageSize, 20));
|
||||
public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.Type == SlotType.User);
|
||||
public override int GetTotalSlots(DatabaseContext database) => database.Slots.Count(s => s.Type == SlotType.User);
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -14,7 +15,7 @@ public class QueueCategory : CategoryWithUser
|
|||
public override string Description { get; set; } = "Your queued content";
|
||||
public override string IconHash { get; set; } = "g820614";
|
||||
public override string Endpoint { get; set; } = "queue";
|
||||
public override Slot? GetPreviewSlot(Database database, User user)
|
||||
public override Slot? GetPreviewSlot(DatabaseContext database, User user)
|
||||
=> database.QueuedLevels.Where(q => q.UserId == user.UserId)
|
||||
.Where(q => q.Slot.Type == SlotType.User && !q.Slot.Hidden && q.Slot.GameVersion <= GameVersion.LittleBigPlanet3)
|
||||
.OrderByDescending(q => q.QueuedLevelId)
|
||||
|
@ -24,7 +25,7 @@ public class QueueCategory : CategoryWithUser
|
|||
.ByGameVersion(GameVersion.LittleBigPlanet3, false, false, true)
|
||||
.FirstOrDefault();
|
||||
|
||||
public override IEnumerable<Slot> GetSlots(Database database, User user, int pageStart, int pageSize)
|
||||
public override IEnumerable<Slot> GetSlots(DatabaseContext database, User user, int pageStart, int pageSize)
|
||||
=> database.QueuedLevels.Where(q => q.UserId == user.UserId)
|
||||
.Where(q => q.Slot.Type == SlotType.User && !q.Slot.Hidden && q.Slot.GameVersion <= GameVersion.LittleBigPlanet3)
|
||||
.OrderByDescending(q => q.QueuedLevelId)
|
||||
|
@ -35,5 +36,5 @@ public class QueueCategory : CategoryWithUser
|
|||
.Skip(Math.Max(0, pageStart - 1))
|
||||
.Take(Math.Min(pageSize, 20));
|
||||
|
||||
public override int GetTotalSlots(Database database, User user) => database.QueuedLevels.Count(q => q.UserId == user.UserId);
|
||||
public override int GetTotalSlots(DatabaseContext database, User user) => database.QueuedLevels.Count(q => q.UserId == user.UserId);
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
|
@ -12,13 +13,13 @@ public class TeamPicksCategory : Category
|
|||
public override string Description { get; set; } = "Community Team Picks";
|
||||
public override string IconHash { get; set; } = "g820626";
|
||||
public override string Endpoint { get; set; } = "team_picks";
|
||||
public override Slot? GetPreviewSlot(Database database) => database.Slots.OrderByDescending(s => s.FirstUploaded).FirstOrDefault(s => s.TeamPick);
|
||||
public override Slot? GetPreviewSlot(DatabaseContext database) => database.Slots.OrderByDescending(s => s.FirstUploaded).FirstOrDefault(s => s.TeamPick);
|
||||
public override IEnumerable<Slot> GetSlots
|
||||
(Database database, int pageStart, int pageSize)
|
||||
(DatabaseContext database, int pageStart, int pageSize)
|
||||
=> database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true)
|
||||
.OrderByDescending(s => s.FirstUploaded)
|
||||
.Where(s => s.TeamPick)
|
||||
.Skip(Math.Max(0, pageStart - 1))
|
||||
.Take(Math.Min(pageSize, 20));
|
||||
public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.TeamPick);
|
||||
public override int GetTotalSlots(DatabaseContext database) => database.Slots.Count(s => s.TeamPick);
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin;
|
||||
|
@ -7,9 +8,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin;
|
|||
[Route("/admin")]
|
||||
public class AdminPanelController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public AdminPanelController(Database database)
|
||||
public AdminPanelController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Files;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -11,9 +12,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin;
|
|||
[Route("/moderation/report/{id:int}")]
|
||||
public class AdminReportController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public AdminReportController(Database database)
|
||||
public AdminReportController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Files;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -15,9 +16,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin;
|
|||
[Route("moderation/user/{id:int}")]
|
||||
public class AdminUserController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public AdminUserController(Database database)
|
||||
public AdminUserController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Types.Users;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -9,9 +10,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Debug;
|
|||
[Route("debug/roomVisualizer")]
|
||||
public class RoomVisualizerController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public RoomVisualizerController(Database database)
|
||||
public RoomVisualizerController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Users;
|
||||
|
@ -11,9 +12,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.ExternalAuth;
|
|||
[Route("/authentication")]
|
||||
public class AuthenticationController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public AuthenticationController(Database database)
|
||||
public AuthenticationController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using LBPUnion.ProjectLighthouse.Administration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -10,9 +10,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Moderator;
|
|||
[Route("moderation/case/{id:int}")]
|
||||
public class ModerationCaseController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public ModerationCaseController(Database database)
|
||||
public ModerationCaseController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
@ -9,9 +10,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Moderator;
|
|||
[Route("moderation")]
|
||||
public class ModerationRemovalController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public ModerationRemovalController(Database database)
|
||||
public ModerationRemovalController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -12,9 +13,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Moderator;
|
|||
[Route("moderation/slot/{id:int}")]
|
||||
public class ModerationSlotController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public ModerationSlotController(Database database)
|
||||
public ModerationSlotController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
|
@ -19,9 +20,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers;
|
|||
[Route("slot/{id:int}")]
|
||||
public class SlotPageController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public SlotPageController(Database database)
|
||||
public SlotPageController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Logging;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -13,9 +14,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers;
|
|||
[Route("user/{id:int}")]
|
||||
public class UserPageController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public UserPageController(Database database)
|
||||
public UserPageController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Middlewares;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
|
@ -11,7 +12,7 @@ public class UserRequiredRedirectMiddleware : MiddlewareDBContext
|
|||
public UserRequiredRedirectMiddleware(RequestDelegate next) : base(next)
|
||||
{ }
|
||||
|
||||
public override async Task InvokeAsync(HttpContext ctx, Database database)
|
||||
public override async Task InvokeAsync(HttpContext ctx, DatabaseContext database)
|
||||
{
|
||||
WebToken? token = database.WebTokenFromRequest(ctx.Request);
|
||||
if (token == null || pathContains(ctx, "/logout"))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -11,7 +12,7 @@ public class AdminApiKeyPageModel : BaseLayout
|
|||
public List<ApiKey> ApiKeys = new();
|
||||
public int KeyCount;
|
||||
|
||||
public AdminApiKeyPageModel(Database database) : base(database)
|
||||
public AdminApiKeyPageModel(DatabaseContext database) : base(database)
|
||||
{ }
|
||||
|
||||
public async Task<IActionResult> OnGet()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Administration.Maintenance;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
|
@ -14,7 +15,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin;
|
|||
public class AdminPanelPage : BaseLayout
|
||||
{
|
||||
public List<ICommand> Commands = MaintenanceHelper.Commands;
|
||||
public AdminPanelPage(Database database) : base(database)
|
||||
public AdminPanelPage(DatabaseContext database) : base(database)
|
||||
{ }
|
||||
|
||||
public List<AdminPanelStatistic> Statistics = new();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -11,7 +12,7 @@ public class AdminPanelUsersPage : BaseLayout
|
|||
public int UserCount;
|
||||
|
||||
public List<User> Users = new();
|
||||
public AdminPanelUsersPage(Database database) : base(database)
|
||||
public AdminPanelUsersPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public async Task<IActionResult> OnGet()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -8,7 +9,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Admin;
|
|||
|
||||
public class AdminSetGrantedSlotsPage : BaseLayout
|
||||
{
|
||||
public AdminSetGrantedSlotsPage(Database database) : base(database)
|
||||
public AdminSetGrantedSlotsPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public User? TargetedUser;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#if DEBUG
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
#endif
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
|
@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug;
|
|||
|
||||
public class FilterTestPage : BaseLayout
|
||||
{
|
||||
public FilterTestPage(Database database) : base(database)
|
||||
public FilterTestPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public string? FilteredText;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
#if !DEBUG
|
||||
|
@ -10,7 +11,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug;
|
|||
|
||||
public class RoomVisualizerPage : BaseLayout
|
||||
{
|
||||
public RoomVisualizerPage(Database database) : base(database)
|
||||
public RoomVisualizerPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public IActionResult OnGet()
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
|
@ -5,7 +6,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug;
|
|||
|
||||
public class VersionInfoPage : BaseLayout
|
||||
{
|
||||
public VersionInfoPage(Database database) : base(database)
|
||||
public VersionInfoPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
public IActionResult OnGet() => this.Page();
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -11,7 +12,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Email;
|
|||
|
||||
public class CompleteEmailVerificationPage : BaseLayout
|
||||
{
|
||||
public CompleteEmailVerificationPage(Database database) : base(database)
|
||||
public CompleteEmailVerificationPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public string? Error;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Email;
|
|||
|
||||
public class SendVerificationEmailPage : BaseLayout
|
||||
{
|
||||
public SendVerificationEmailPage(Database database) : base(database)
|
||||
public SendVerificationEmailPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public bool Success { get; set; }
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#nullable enable
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Localization.StringLists;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
|
@ -13,7 +14,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Email;
|
|||
|
||||
public class SetEmailForm : BaseLayout
|
||||
{
|
||||
public SetEmailForm(Database database) : base(database)
|
||||
public SetEmailForm(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public string? Error { get; private set; }
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
|
@ -5,7 +6,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Errors;
|
|||
|
||||
public class NotFoundPage : BaseLayout
|
||||
{
|
||||
public NotFoundPage(Database database) : base(database)
|
||||
public NotFoundPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public IActionResult OnGet() => this.Page();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using System.Net;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -12,7 +13,7 @@ public class AuthenticationPage : BaseLayout
|
|||
public List<PlatformLinkAttempt> LinkAttempts = new();
|
||||
|
||||
public IPAddress? IpAddress;
|
||||
public AuthenticationPage(Database database) : base(database)
|
||||
public AuthenticationPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public IActionResult OnGet()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using JetBrains.Annotations;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
|
@ -12,7 +13,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages;
|
|||
|
||||
public class LandingPage : BaseLayout
|
||||
{
|
||||
public LandingPage(Database database) : base(database)
|
||||
public LandingPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public int PendingAuthAttempts;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Localization;
|
||||
using LBPUnion.ProjectLighthouse.Localization.StringLists;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Types;
|
||||
|
@ -11,7 +12,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
|||
|
||||
public class BaseLayout : PageModel
|
||||
{
|
||||
public readonly Database Database;
|
||||
public readonly DatabaseContext Database;
|
||||
|
||||
public readonly List<PageNavigationItem> NavigationItems = new();
|
||||
|
||||
|
@ -25,7 +26,7 @@ public class BaseLayout : PageModel
|
|||
public string Title = string.Empty;
|
||||
|
||||
private User? user;
|
||||
public BaseLayout(Database database)
|
||||
public BaseLayout(DatabaseContext database)
|
||||
{
|
||||
this.Database = database;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Web;
|
||||
using JetBrains.Annotations;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Localization.StringLists;
|
||||
|
@ -17,7 +18,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
|
|||
|
||||
public class LoginForm : BaseLayout
|
||||
{
|
||||
public LoginForm(Database database) : base(database)
|
||||
public LoginForm(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public string? Error { get; private set; }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -7,7 +8,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
|
|||
|
||||
public class LogoutPage : BaseLayout
|
||||
{
|
||||
public LogoutPage(Database database) : base(database)
|
||||
public LogoutPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
public async Task<IActionResult> OnGet()
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#nullable enable
|
||||
using JetBrains.Annotations;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -10,7 +11,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
|
|||
|
||||
public class PasswordResetPage : BaseLayout
|
||||
{
|
||||
public PasswordResetPage(Database database) : base(database)
|
||||
public PasswordResetPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public string? Error { get; private set; }
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using JetBrains.Annotations;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -16,7 +17,7 @@ public class PasswordResetRequestForm : BaseLayout
|
|||
|
||||
public string? Status { get; private set; }
|
||||
|
||||
public PasswordResetRequestForm(Database database) : base(database)
|
||||
public PasswordResetRequestForm(DatabaseContext database) : base(database)
|
||||
{ }
|
||||
|
||||
[UsedImplicitly]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -7,7 +8,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
|
|||
|
||||
public class PasswordResetRequiredPage : BaseLayout
|
||||
{
|
||||
public PasswordResetRequiredPage(Database database) : base(database)
|
||||
public PasswordResetRequiredPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public bool WasResetRequest { get; private set; }
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -6,7 +7,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
|
|||
|
||||
public class PirateSignupPage : BaseLayout
|
||||
{
|
||||
public PirateSignupPage(Database database) : base(database)
|
||||
public PirateSignupPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public IActionResult OnGet()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using JetBrains.Annotations;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Extensions;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Localization.StringLists;
|
||||
|
@ -14,7 +15,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Login;
|
|||
|
||||
public class RegisterForm : BaseLayout
|
||||
{
|
||||
public RegisterForm(Database database) : base(database)
|
||||
public RegisterForm(DatabaseContext database) : base(database)
|
||||
{ }
|
||||
|
||||
public string? Error { get; private set; }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
|
@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation;
|
|||
|
||||
public class BannedUsersPage : BaseLayout
|
||||
{
|
||||
public BannedUsersPage(Database database) : base(database)
|
||||
public BannedUsersPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public List<User> Users = new();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation;
|
|||
|
||||
public class CasePage : BaseLayout
|
||||
{
|
||||
public CasePage(Database database) : base(database)
|
||||
public CasePage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public List<ModerationCase> Cases = new();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
|
||||
|
@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation;
|
|||
|
||||
public class HiddenLevelsPage : BaseLayout
|
||||
{
|
||||
public HiddenLevelsPage(Database database) : base(database)
|
||||
public HiddenLevelsPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public int PageAmount;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
@page "/moderation"
|
||||
@using System.Diagnostics
|
||||
@using LBPUnion.ProjectLighthouse.Administration
|
||||
@using LBPUnion.ProjectLighthouse.Extensions
|
||||
@using LBPUnion.ProjectLighthouse.Localization.StringLists
|
||||
@using LBPUnion.ProjectLighthouse.Servers.Website.Types
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Types;
|
||||
|
@ -8,7 +9,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation;
|
|||
|
||||
public class ModPanelPage : BaseLayout
|
||||
{
|
||||
public ModPanelPage(Database database) : base(database)
|
||||
public ModPanelPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public List<AdminPanelStatistic> Statistics = new();
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -8,7 +9,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation;
|
|||
|
||||
public class NewCasePage : BaseLayout
|
||||
{
|
||||
public NewCasePage(Database database) : base(database)
|
||||
public NewCasePage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public CaseType Type { get; set; }
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Text.Json;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -10,7 +11,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Moderation;
|
|||
|
||||
public class ReportPage : BaseLayout
|
||||
{
|
||||
public ReportPage(Database database) : base(database)
|
||||
public ReportPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public GriefReport Report = null!; // Report is not used if it's null in OnGet
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#nullable enable
|
||||
using System.Text.Json;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -22,7 +23,7 @@ public class ReportsPage : BaseLayout
|
|||
|
||||
public string SearchValue = "";
|
||||
|
||||
public ReportsPage(Database database) : base(database)
|
||||
public ReportsPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
@using LBPUnion.ProjectLighthouse
|
||||
@using LBPUnion.ProjectLighthouse.Database
|
||||
@using LBPUnion.ProjectLighthouse.Localization
|
||||
@using LBPUnion.ProjectLighthouse.Servers.Website.Extensions
|
||||
@using LBPUnion.ProjectLighthouse.Types.Entities.Level
|
||||
|
@ -25,7 +25,7 @@
|
|||
{
|
||||
Score score = Model.Scores[i];
|
||||
string[] playerIds = score.PlayerIds;
|
||||
Database database = Model.Database;
|
||||
DatabaseContext database = Model.Database;
|
||||
<div class="item">
|
||||
<span class="ui large text">
|
||||
@if(canDelete)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
@using System.Diagnostics
|
||||
@using LBPUnion.ProjectLighthouse
|
||||
@using LBPUnion.ProjectLighthouse.Database
|
||||
@using LBPUnion.ProjectLighthouse.Types.Entities.Level
|
||||
@using LBPUnion.ProjectLighthouse.Types.Entities.Profile
|
||||
@using LBPUnion.ProjectLighthouse.Types.Moderation.Cases
|
||||
@model LBPUnion.ProjectLighthouse.Types.Entities.Moderation.ModerationCase
|
||||
|
||||
@{
|
||||
Database database = new();
|
||||
DatabaseContext database = new();
|
||||
string color = "blue";
|
||||
|
||||
string timeZone = (string?)ViewData["TimeZone"] ?? TimeZoneInfo.Local.Id;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@using System.Web
|
||||
@using LBPUnion.ProjectLighthouse
|
||||
@using LBPUnion.ProjectLighthouse.Configuration
|
||||
@using LBPUnion.ProjectLighthouse.Database
|
||||
@using LBPUnion.ProjectLighthouse.Localization
|
||||
@using LBPUnion.ProjectLighthouse.Servers.Website.Extensions
|
||||
@using LBPUnion.ProjectLighthouse.Types.Entities.Profile
|
||||
|
@ -11,7 +11,7 @@
|
|||
@{
|
||||
User? user = (User?)ViewData["User"];
|
||||
|
||||
await using Database database = new();
|
||||
await using DatabaseContext database = new();
|
||||
|
||||
string slotName = HttpUtility.HtmlDecode(string.IsNullOrEmpty(Model!.Name) ? "Unnamed Level" : Model.Name);
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -19,7 +20,7 @@ public class PhotosPage : BaseLayout
|
|||
public List<Photo> Photos = new();
|
||||
|
||||
public string? SearchValue;
|
||||
public PhotosPage(Database database) : base(database)
|
||||
public PhotosPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
|
@ -22,7 +23,7 @@ public class SlotPage : BaseLayout
|
|||
public readonly bool ReviewsEnabled = ServerConfiguration.Instance.UserGeneratedContentLimits.LevelReviewsEnabled;
|
||||
|
||||
public Slot? Slot;
|
||||
public SlotPage(Database database) : base(database)
|
||||
public SlotPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public async Task<IActionResult> OnGet([FromRoute] int id)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Files;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
|
@ -12,7 +13,7 @@ public class SlotSettingsPage : BaseLayout
|
|||
{
|
||||
|
||||
public Slot? Slot;
|
||||
public SlotSettingsPage(Database database) : base(database)
|
||||
public SlotSettingsPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public async Task<IActionResult> OnPost([FromRoute] int slotId, [FromForm] string? avatar, [FromForm] string? name, [FromForm] string? description, string? labels)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#nullable enable
|
||||
using System.Text;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
|
@ -23,7 +24,7 @@ public class SlotsPage : BaseLayout
|
|||
|
||||
public string? SearchValue;
|
||||
|
||||
public SlotsPage(Database database) : base(database)
|
||||
public SlotsPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Localization.StringLists;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
|
@ -9,7 +10,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.TwoFactor;
|
|||
|
||||
public class DisableTwoFactorPage : BaseLayout
|
||||
{
|
||||
public DisableTwoFactorPage(Database database) : base(database) { }
|
||||
public DisableTwoFactorPage(DatabaseContext database) : base(database) { }
|
||||
|
||||
public string Error { get; set; } = "";
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Security.Cryptography;
|
|||
using System.Text;
|
||||
using System.Web;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Localization.StringLists;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
|
@ -19,7 +20,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.TwoFactor;
|
|||
|
||||
public class SetupTwoFactorPage : BaseLayout
|
||||
{
|
||||
public SetupTwoFactorPage(Database database) : base(database)
|
||||
public SetupTwoFactorPage(DatabaseContext database) : base(database)
|
||||
{ }
|
||||
|
||||
public string QrCode { get; set; } = "";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Localization.StringLists;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
|
@ -11,7 +12,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.TwoFactor;
|
|||
|
||||
public class TwoFactorLoginPage : BaseLayout
|
||||
{
|
||||
public TwoFactorLoginPage(Database database) : base(database)
|
||||
public TwoFactorLoginPage(DatabaseContext database) : base(database)
|
||||
{ }
|
||||
|
||||
public string Error { get; set; } = "";
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
|
||||
|
@ -28,7 +29,7 @@ public class UserPage : BaseLayout
|
|||
public List<Slot>? QueuedSlots;
|
||||
|
||||
public User? ProfileUser;
|
||||
public UserPage(Database database) : base(database)
|
||||
public UserPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public async Task<IActionResult> OnGet([FromRoute] int userId)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#nullable enable
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Files;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Localization;
|
||||
|
@ -15,7 +16,7 @@ public class UserSettingsPage : BaseLayout
|
|||
{
|
||||
|
||||
public User? ProfileUser;
|
||||
public UserSettingsPage(Database database) : base(database)
|
||||
public UserSettingsPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
[SuppressMessage("ReSharper", "SpecifyStringComparison")]
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
using LBPUnion.ProjectLighthouse.Types.Users;
|
||||
|
@ -20,7 +21,7 @@ public class UsersPage : BaseLayout
|
|||
|
||||
public string? SearchValue;
|
||||
|
||||
public UsersPage(Database database) : base(database)
|
||||
public UsersPage(DatabaseContext database) : base(database)
|
||||
{}
|
||||
|
||||
public async Task<IActionResult> OnGet([FromRoute] int pageNumber, [FromQuery] string? name)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Globalization;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Localization;
|
||||
using LBPUnion.ProjectLighthouse.Middlewares;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Middlewares;
|
||||
|
@ -40,7 +41,7 @@ public class WebsiteStartup
|
|||
services.AddRazorPages().WithRazorPagesAtContentRoot();
|
||||
#endif
|
||||
|
||||
services.AddDbContext<Database>();
|
||||
services.AddDbContext<DatabaseContext>();
|
||||
|
||||
services.Configure<ForwardedHeadersOptions>
|
||||
(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup;
|
||||
using LBPUnion.ProjectLighthouse.Tests;
|
||||
|
@ -14,7 +14,7 @@ public class DatabaseTests : LighthouseServerTest<GameServerTestStartup>
|
|||
[DatabaseFact]
|
||||
public async Task CanCreateUserTwice()
|
||||
{
|
||||
await using Database database = new();
|
||||
await using DatabaseContext database = new();
|
||||
int rand = new Random().Next();
|
||||
|
||||
User userA = await database.CreateUser("unitTestUser" + rand, CryptoHelper.GenerateAuthToken());
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup;
|
||||
using LBPUnion.ProjectLighthouse.Tests;
|
||||
|
@ -86,7 +86,7 @@ public class LoginTests : LighthouseServerTest<GameServerTestStartup>
|
|||
{
|
||||
string username = await this.CreateRandomUser();
|
||||
ulong userId = (ulong)Convert.ToInt32(username["unitTestUser".Length..]);
|
||||
await using Database database = new();
|
||||
await using DatabaseContext database = new();
|
||||
User user = await database.Users.FirstAsync(u => u.Username == username);
|
||||
user.PermissionLevel = PermissionLevel.Banned;
|
||||
await database.SaveChangesAsync();
|
||||
|
|
|
@ -2,7 +2,7 @@ using System;
|
|||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup;
|
||||
using LBPUnion.ProjectLighthouse.Tests;
|
||||
|
@ -47,7 +47,7 @@ public class MatchTests : LighthouseServerTest<GameServerTestStartup>
|
|||
|
||||
await semaphore.WaitAsync();
|
||||
|
||||
await using Database database = new();
|
||||
await using DatabaseContext database = new();
|
||||
|
||||
int oldPlayerCount = await StatisticsHelper.RecentMatches(database);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Servers.GameServer.Startup;
|
||||
using LBPUnion.ProjectLighthouse.Tests;
|
||||
|
@ -18,7 +18,7 @@ public class SlotTests : LighthouseServerTest<GameServerTestStartup>
|
|||
[DatabaseFact]
|
||||
public async Task ShouldOnlyShowUsersLevels()
|
||||
{
|
||||
await using Database database = new();
|
||||
await using DatabaseContext database = new();
|
||||
|
||||
Random r = new();
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Tests;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -18,7 +18,7 @@ public class AdminTests : LighthouseWebTest
|
|||
[DatabaseFact]
|
||||
public async Task ShouldShowAdminPanelButtonWhenAdmin()
|
||||
{
|
||||
await using Database database = new();
|
||||
await using DatabaseContext database = new();
|
||||
Random random = new();
|
||||
User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("i'm an engineering failure"));
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class AdminTests : LighthouseWebTest
|
|||
[DatabaseFact]
|
||||
public async Task ShouldNotShowAdminPanelButtonWhenNotAdmin()
|
||||
{
|
||||
await using Database database = new();
|
||||
await using DatabaseContext database = new();
|
||||
Random random = new();
|
||||
User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("i'm an engineering failure"));
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Tests;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -17,7 +17,7 @@ public class AuthenticationTests : LighthouseWebTest
|
|||
[DatabaseFact]
|
||||
public async Task ShouldLoginWithPassword()
|
||||
{
|
||||
await using Database database = new();
|
||||
await using DatabaseContext database = new();
|
||||
Random random = new();
|
||||
|
||||
string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray());
|
||||
|
@ -39,7 +39,7 @@ public class AuthenticationTests : LighthouseWebTest
|
|||
[DatabaseFact]
|
||||
public async Task ShouldNotLoginWithNoPassword()
|
||||
{
|
||||
await using Database database = new();
|
||||
await using DatabaseContext database = new();
|
||||
Random random = new();
|
||||
User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("just like the hindenberg,"));
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class AuthenticationTests : LighthouseWebTest
|
|||
[DatabaseFact]
|
||||
public async Task ShouldNotLoginWithWrongPassword()
|
||||
{
|
||||
await using Database database = new();
|
||||
await using DatabaseContext database = new();
|
||||
Random random = new();
|
||||
User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("i'm an engineering failure"));
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class AuthenticationTests : LighthouseWebTest
|
|||
{
|
||||
const string loggedInAsUsernameTextXPath = "/html/body/div/div/div/div/p[1]";
|
||||
|
||||
await using Database database = new();
|
||||
await using DatabaseContext database = new();
|
||||
Random random = new();
|
||||
User user = await database.CreateUser($"unitTestUser{random.Next()}", CryptoHelper.BCryptHash("i'm an engineering failure"));
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Tests;
|
||||
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
|
||||
|
@ -16,7 +16,7 @@ public class RegisterTests : LighthouseWebTest
|
|||
[DatabaseFact]
|
||||
public async Task ShouldRegister()
|
||||
{
|
||||
await using Database database = new();
|
||||
await using DatabaseContext database = new();
|
||||
|
||||
string username = ("unitTestUser" + new Random().Next()).Substring(0, 16);
|
||||
string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray());
|
||||
|
@ -41,7 +41,7 @@ public class RegisterTests : LighthouseWebTest
|
|||
[DatabaseFact]
|
||||
public async Task ShouldNotRegisterWithMismatchingPasswords()
|
||||
{
|
||||
await using Database database = new();
|
||||
await using DatabaseContext database = new();
|
||||
|
||||
string username = ("unitTestUser" + new Random().Next()).Substring(0, 16);
|
||||
string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray());
|
||||
|
@ -64,7 +64,7 @@ public class RegisterTests : LighthouseWebTest
|
|||
[DatabaseFact]
|
||||
public async Task ShouldNotRegisterWithTakenUsername()
|
||||
{
|
||||
await using Database database = new();
|
||||
await using DatabaseContext database = new();
|
||||
|
||||
string username = ("unitTestUser" + new Random().Next())[..16];
|
||||
string password = CryptoHelper.Sha256Hash(CryptoHelper.GenerateRandomBytes(64).ToArray());
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using LBPUnion.ProjectLighthouse.Configuration;
|
||||
using LBPUnion.ProjectLighthouse.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Xunit;
|
||||
|
||||
|
@ -15,7 +16,7 @@ public sealed class DatabaseFactAttribute : FactAttribute
|
|||
else
|
||||
lock (migrateLock)
|
||||
{
|
||||
using Database database = new();
|
||||
using DatabaseContext database = new();
|
||||
database.Database.Migrate();
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue