Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
<PackageVersion Include="AutoMapper" Version="13.0.1" />
<PackageVersion Include="BuildBundlerMinifier" Version="3.2.449" />
<PackageVersion Include="IdentityModel" Version="7.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SQLite" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.1" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="9.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SQLite" Version="9.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.1" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Microsoft.Web.LibraryManager.Build" Version="2.1.175" />
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.3" />
<PackageVersion Include="Serilog.Settings.Configuration" Version="8.0.4" />
<PackageVersion Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageVersion Include="Serilog.Settings.Configuration" Version="9.0.0" />
<PackageVersion Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageVersion Include="Serilog.Sinks.MSSqlServer" Version="8.0.0" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.2.1" />
<PackageVersion Include="System.Text.Json" Version="9.0.0" />
<PackageVersion Include="Shouldly" Version="4.2.1" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="Serilog.Sinks.MSSqlServer" Version="8.1.0" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.4.0" />
<PackageVersion Include="System.Text.Json" Version="9.0.1" />
<PackageVersion Include="Shouldly" Version="4.3.0" />
<PackageVersion Include="xunit.v3" Version="1.1.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
</ItemGroup>
</Project>
5 changes: 2 additions & 3 deletions src/RDMG.Core/ConfigureServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using RDMG.Core.Abstractions.Services;
using RDMG.Core.Generator;
using RDMG.Core.Services;
using System;
using RDMG.Core.Services.Automapper;

namespace RDMG.Core;

Expand All @@ -22,8 +22,7 @@ this IServiceCollection services
.AddScoped<IDungeonNoCorridor, DungeonNoCorridor>()
.AddScoped<IDungeonService, DungeonService>();

services.AddAutoMapper(cfg => { cfg.AllowNullCollections = true; }
, AppDomain.CurrentDomain.GetAssemblies());
services.AddAutoMapper(cfg => { cfg.AllowNullCollections = true; }, typeof(DungeonProfile));

return services;
}
Expand Down
32 changes: 19 additions & 13 deletions src/RDMG.Infrastructure/ConfigureServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
using System;
using System.IO;
using System.Reflection;
using RDMG.Infrastructure.Repository.Automapper;

namespace RDMG.Infrastructure;

public static class ConfigureServices
{
public static IServiceCollection AddInfrastructureServices(
Expand All @@ -26,10 +28,11 @@ public static IServiceCollection AddInfrastructureServices(
services.AddDbContext<SqlServerContext>((sp, options) =>
{
options.UseSqlServer(configuration.GetConnectionString(AppDbContext.Rdmg),
sqlServerOptionsAction: sqlOptions =>
{
sqlOptions.MigrationsAssembly(typeof(SqlServerContext).GetTypeInfo().Assembly.GetName().Name);
})
sqlServerOptionsAction: sqlOptions =>
{
sqlOptions.MigrationsAssembly(typeof(SqlServerContext).GetTypeInfo().Assembly.GetName()
.Name);
})
.AddInterceptors(
ActivatorUtilities.CreateInstance<AuditEntitiesSaveChangesInterceptor>(sp));
});
Expand All @@ -44,10 +47,11 @@ public static IServiceCollection AddInfrastructureServices(
services.AddDbContext<SqliteContext>((sp, options) =>
{
options.UseSqlite(connString?.Replace(SqliteContext.HomeToken, home),
sqliteOptionsAction: sqlOptions =>
{
sqlOptions.MigrationsAssembly(typeof(SqliteContext).GetTypeInfo().Assembly.GetName().Name);
})
sqliteOptionsAction: sqlOptions =>
{
sqlOptions.MigrationsAssembly(typeof(SqliteContext).GetTypeInfo().Assembly.GetName()
.Name);
})
.AddInterceptors(
ActivatorUtilities.CreateInstance<AuditEntitiesSaveChangesInterceptor>(sp));
});
Expand All @@ -58,7 +62,8 @@ public static IServiceCollection AddInfrastructureServices(
break;
default:
throw new ServiceException(
string.Format(Resources.Error.DbProviderError, configuration.GetConnectionString(AppDbContext.DbProvider)));
string.Format(Resources.Error.DbProviderError,
configuration.GetConnectionString(AppDbContext.DbProvider)));
}

Configure(services, configuration);
Expand All @@ -74,6 +79,7 @@ private static void Configure(IServiceCollection services, IConfiguration config
.AddScoped<IDungeonOptionRepository, DungeonOptionRepository>()
.AddScoped<IOptionRepository, OptionRepository>()
.AddScoped<IUserRepository, UserRepository>();
services.AddAutoMapper(cfg => { cfg.AllowNullCollections = true; }, typeof(DungeonProfile));
}

public static IServiceCollection AddTestInfrastructureServices(this IServiceCollection services,
Expand All @@ -83,10 +89,10 @@ public static IServiceCollection AddTestInfrastructureServices(this IServiceColl
services.AddDbContext<SqliteContext>((sp, options) =>
{
options.UseSqlite(connection,
sqliteOptionsAction: sqlOptions =>
{
sqlOptions.MigrationsAssembly(typeof(SqliteContext).GetTypeInfo().Assembly.GetName().Name);
})
sqliteOptionsAction: sqlOptions =>
{
sqlOptions.MigrationsAssembly(typeof(SqliteContext).GetTypeInfo().Assembly.GetName().Name);
})
.AddInterceptors(ActivatorUtilities.CreateInstance<AuditEntitiesSaveChangesInterceptor>(sp));
});
services.AddScoped<IAppDbContext, SqliteContext>(sp =>
Expand Down
7 changes: 4 additions & 3 deletions src/RDMG.Web/ConfigureServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using RDMG.Core.Abstractions.Services;
using RDMG.Core.Abstractions.Services.Exceptions;
using RDMG.Infrastructure.Data;
using RDMG.Web.Automapper;
using RDMG.Web.Services;
using Serilog;

Expand All @@ -16,7 +17,7 @@ public static IServiceCollection AddWebServices(this IServiceCollection services
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = _ => true;
options.CheckConsentNeeded = _ => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
Expand All @@ -25,7 +26,7 @@ public static IServiceCollection AddWebServices(this IServiceCollection services
options.LoginPath = new PathString("/Auth/Login");
options.AccessDeniedPath = new PathString("/Auth/Forbidden/");
});

services.AddAutoMapper(cfg => { cfg.AllowNullCollections = true; }, typeof(AuthProfile));
services.AddMemoryCache();

services.AddMvc()
Expand Down Expand Up @@ -56,7 +57,7 @@ public static IHostBuilder AddSerilog(this IHostBuilder host,
default:
throw new ServiceException(
string.Format(Resources.Error.DbProviderError,
configuration.GetConnectionString(AppDbContext.DbProvider)));
configuration.GetConnectionString(AppDbContext.DbProvider)));
}

return host;
Expand Down
2 changes: 1 addition & 1 deletion src/RDMG.Web/RDMG.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<TieredCompilation>true</TieredCompilation>
<PreserveCompilationReferences>true</PreserveCompilationReferences>
<AssemblyVersion>1.0.2.0</AssemblyVersion>
<AssemblyVersion>1.0.3.0</AssemblyVersion>
<UserSecretsId>b2a492d1-90ea-4e42-b3e5-5d962495bef1</UserSecretsId>
</PropertyGroup>
<ItemGroup>
Expand Down
6 changes: 0 additions & 6 deletions src/RDMG.Web/Views/Home/Privacy.cshtml

This file was deleted.

27 changes: 0 additions & 27 deletions src/RDMG.Web/Views/Shared/_CookieConsentPartial.cshtml

This file was deleted.

81 changes: 42 additions & 39 deletions src/RDMG.Web/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
@@ -1,54 +1,57 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>@ViewData["Title"] - RDMG</title>
<partial name="_StylesPartial" />
<partial name="_StylesPartial"/>
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">@Resources.Common.NavHome</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex ">
<ul class="navbar-nav flex-grow-1">
@if (User.Identity!.IsAuthenticated)
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">@Resources.Common.NavHome</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse"
aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex ">
<ul class="navbar-nav flex-grow-1">
@if (User.Identity!.IsAuthenticated)
{
if (User.Claims.Any(c => c.Value == RDMG.Core.Domain.Roles.Admin))
{
if (User.Claims.Any(c => c.Value == RDMG.Core.Domain.Roles.Admin))
{
<li class="nav-item"><a class="nav-link text-dark" asp-area="" asp-controller="User" asp-action="Index">@Resources.Common.NavUserManagement </a></li>
}
<li class="nav-item"><a class="nav-link text-dark" asp-area="" asp-controller="Dungeon" asp-action="Index">@Resources.Common.NavDungeons</a></li>
<li class="nav-item"><a class="nav-link text-dark" asp-area="" asp-controller="User"
asp-action="Index">@Resources.Common.NavUserManagement </a></li>
}
</ul>
<ul class="navbar-nav ml-auto">
<partial name="_Login" />
</ul>
</div>

<li class="nav-item"><a class="nav-link text-dark" asp-area="" asp-controller="Dungeon"
asp-action="Index">@Resources.Common.NavDungeons</a></li>
}
</ul>
<ul class="navbar-nav ml-auto">
<partial name="_Login"/>
</ul>
</div>
</nav>
</header>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>

<footer class="border-top footer text-muted text-center">
<div class="container">
<partial name="_CookieConsentPartial" />
<main role="main" class="pb-3">
@RenderBody()
</main>
&copy; @DateTime.Now.Year @Resources.Common.Copyright - @System.Reflection.Assembly.GetEntryAssembly()?.GetName().Version?.ToString()
</div>
</footer>

<footer class="border-top footer text-muted text-center">
<div class="container">
&copy; @DateTime.Now.Year @Resources.Common.Copyright - @System.Reflection.Assembly.GetEntryAssembly()?.GetName().Version?.ToString() - <a asp-area="" asp-controller="Home" asp-action="Privacy">@Resources.Common.Privacy</a>
</div>
</footer>

<em class="far fa-arrow-alt-circle-up toparrow" onclick="topFunction()" style="display:none"></em>
<em class="far fa-arrow-alt-circle-up toparrow" onclick="topFunction()" style="display:none"></em>

<partial name="_ScriptsPartial" />
@RenderSection("Scripts", required: false)
<partial name="_ScriptsPartial"/>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>
7 changes: 4 additions & 3 deletions src/RDMG.Web/Views/Shared/_Login.cshtml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
@using RDMG.Web.Helpers
@if (User?.Identity?.IsAuthenticated == true)
@if (User.Identity?.IsAuthenticated == true)
{
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="menuProfile" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<a class="nav-link dropdown-toggle" href="#" id="menuProfile" role="button" data-bs-toggle="dropdown"
aria-expanded="false">
<i class="fa fa-user fa-fw"></i>
<span class="">
@UserHelper.GetUserName(User?.Claims)
@UserHelper.GetUserName(User.Claims)
</span>
</a>
<div class="dropdown-menu" aria-labelledby="menuProfile">
Expand Down
Loading