Skip to content

Commit

Permalink
Code cleanup, package updates, minor config updates
Browse files Browse the repository at this point in the history
  • Loading branch information
emonney committed Feb 8, 2024
1 parent a8cf3ad commit 5f99103
Show file tree
Hide file tree
Showing 30 changed files with 1,463 additions and 2,352 deletions.
4 changes: 2 additions & 2 deletions QuickApp.Core/QuickApp.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
<Copyright>Copyright © 2023 www.ebenmonney.com</Copyright>
<PackageProjectUrl>https://www.ebenmonney.com/quickapp</PackageProjectUrl>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace QuickApp.Server.Authorization
{
// Swagger IOperationFilter implementation that will decide which api action needs authorization
internal class SwaggerAuthorizeCheckFilter : IOperationFilter
internal class SwaggerAuthorizeOperationFilter : IOperationFilter
{
public void Apply(OpenApiOperation operation, OperationFilterContext context)
{
Expand Down
18 changes: 9 additions & 9 deletions QuickApp.Server/Controllers/UserAccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public async Task<IActionResult> UpdateUser(string id, [FromBody] UserEditVM use
return NotFound(id);

if (!string.IsNullOrWhiteSpace(user.Id) && id != user.Id)
AddModelError("Conflicting user id in parameter and model data", nameof(id));
AddModelError("Conflicting user id in parameter and model data.", nameof(id));

var isNewPassword = !string.IsNullOrWhiteSpace(user.NewPassword);
var isNewUserName = !appUser.UserName!.Equals(user.UserName, StringComparison.OrdinalIgnoreCase);
Expand All @@ -145,10 +145,10 @@ public async Task<IActionResult> UpdateUser(string id, [FromBody] UserEditVM use
if (string.IsNullOrWhiteSpace(user.CurrentPassword))
{
if (isNewPassword)
AddModelError("Current password is required when changing your own password", "Password");
AddModelError("Current password is required when changing your own password.", "Password");

if (isNewUserName)
AddModelError("Current password is required when changing your own username", "Username");
AddModelError("Current password is required when changing your own username.", "Username");
}
else if (isNewPassword || isNewUserName)
{
Expand Down Expand Up @@ -189,8 +189,7 @@ public async Task<IActionResult> UpdateUser(string id, [FromBody] UserEditVM use
[ProducesResponseType(400)]
public async Task<IActionResult> UpdateCurrentUser([FromBody] JsonPatchDocument<UserPatchVM> patch)
{
var userId = GetCurrentUserId();
return await UpdateUser(userId, patch);
return await UpdateUser(GetCurrentUserId(), patch);
}

[HttpPatch("users/{id}")]
Expand Down Expand Up @@ -238,11 +237,11 @@ public async Task<IActionResult> Register([FromBody] UserEditVM user)
return new ChallengeResult();

if (string.IsNullOrWhiteSpace(user.NewPassword))
AddModelError($"{nameof(user.NewPassword)} is required when registering a new user",
AddModelError($"{nameof(user.NewPassword)} is required when registering a new user.",
nameof(user.NewPassword));

if (user.Roles == null)
AddModelError($"{nameof(user.Roles)} is required when registering a new user", nameof(user.Roles));
AddModelError($"{nameof(user.Roles)} is required when registering a new user.", nameof(user.Roles));

if (ModelState.IsValid)
{
Expand Down Expand Up @@ -281,7 +280,7 @@ public async Task<IActionResult> DeleteUser(string id)
if (!canDelete.Success)
{
AddModelError($"User \"{appUser.UserName}\" cannot be deleted at this time. " +
"Delete the associated records and try again");
"Delete the associated records and try again.");
AddModelError(canDelete.Errors, "Records");
}

Expand Down Expand Up @@ -352,7 +351,8 @@ public async Task<IActionResult> UserPreferences([FromBody] string data)

if (!result.Succeeded)
{
throw new UserAccountException($"The following errors occurred whilst updating User Configurations: " +
throw new UserAccountException(
$"The following errors occurred whilst updating User Configurations: " +
$"{string.Join(", ", result.Errors)}");
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
// ---------------------------------------
// Email: [email protected]
// Templates: www.ebenmonney.com/templates
// (c) 2024 www.ebenmonney.com/mit-license
// ---------------------------------------

using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable
Expand Down
10 changes: 2 additions & 8 deletions QuickApp.Server/Migrations/ApplicationDbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
// ---------------------------------------
// Email: [email protected]
// Templates: www.ebenmonney.com/templates
// (c) 2024 www.ebenmonney.com/mit-license
// ---------------------------------------

// <auto-generated />
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
Expand All @@ -23,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("ProductVersion", "8.0.1")
.HasAnnotation("Relational:MaxIdentifierLength", 128);

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
Expand Down
8 changes: 3 additions & 5 deletions QuickApp.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
}
else
{
var oidcCertFileName = builder.Configuration["Certificates:OIDC:Path"];
var oidcCertFilePassword = builder.Configuration["Certificates:OIDC:Password"];
var oidcCertFileName = builder.Configuration["OIDC:Certificates:Path"];
var oidcCertFilePassword = builder.Configuration["OIDC:Certificates:Password"];

if (string.IsNullOrWhiteSpace(oidcCertFileName))
{
Expand All @@ -122,7 +122,6 @@
}
else
{
//Todo: //Testa: test me
var oidcCertificate = new X509Certificate2(oidcCertFileName, oidcCertFilePassword);

options.AddEncryptionCertificate(oidcCertificate)
Expand Down Expand Up @@ -171,7 +170,7 @@
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = OidcServerConfig.ServerName, Version = "v1" });
c.OperationFilter<SwaggerAuthorizeCheckFilter>();
c.OperationFilter<SwaggerAuthorizeOperationFilter>();
c.AddSecurityDefinition("oauth2", new OpenApiSecurityScheme
{
Type = SecuritySchemeType.OAuth2,
Expand All @@ -198,7 +197,6 @@
builder.Services.AddScoped<IOrdersService, OrdersService>();

// Other Services
//builder.Services.AddHttpContextAccessor(); // Todo: Test if needed. If IUserIdAccessor works
builder.Services.AddScoped<IEmailSender, EmailSender>();
builder.Services.AddScoped<IUserIdAccessor, UserIdAccessor>();

Expand Down
95 changes: 49 additions & 46 deletions QuickApp.Server/QuickApp.Server.csproj
Original file line number Diff line number Diff line change
@@ -1,52 +1,55 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>false</InvariantGlobalization>
<SpaRoot>..\quickapp.client</SpaRoot>
<SpaProxyLaunchCommand>npm start</SpaProxyLaunchCommand>
<SpaProxyServerUrl>https://localhost:4200</SpaProxyServerUrl>
<Version>8.0.0</Version>
<Company>www.ebenmonney.com</Company>
<Authors>$(Company)</Authors>
<Description>ASPNET Core 8.0 - Angular 17 startup template for Quick Application Development</Description>
<Copyright>Copyright © 2023 www.ebenmonney.com</Copyright>
<PackageProjectUrl>https://www.ebenmonney.com/quickapp</PackageProjectUrl>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>false</InvariantGlobalization>
<SpaRoot>..\quickapp.client</SpaRoot>
<SpaProxyLaunchCommand>npm start</SpaProxyLaunchCommand>
<SpaProxyServerUrl>https://localhost:4200</SpaProxyServerUrl>
<Version>8.0.0</Version>
<Company>www.ebenmonney.com</Company>
<Authors>$(Company)</Authors>
<Description>ASPNET Core 8.0 - Angular 17 startup template for Quick Application Development</Description>
<Copyright>Copyright © 2023 www.ebenmonney.com</Copyright>
<PackageProjectUrl>https://www.ebenmonney.com/quickapp</PackageProjectUrl>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageReference Include="MailKit" Version="4.3.0" />
<PackageReference Include="OpenIddict.AspNetCore" Version="5.0.1" />
<PackageReference Include="OpenIddict.EntityFrameworkCore" Version="5.0.1" />
<PackageReference Include="OpenIddict.Quartz" Version="5.0.1" />
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.8.0" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaProxy">
<Version>8.*-*</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageReference Include="MailKit" Version="4.3.0" />
<PackageReference Include="OpenIddict.AspNetCore" Version="5.1.0" />
<PackageReference Include="OpenIddict.EntityFrameworkCore" Version="5.1.0" />
<PackageReference Include="OpenIddict.Quartz" Version="5.1.0" />
<PackageReference Include="Quartz.Extensions.Hosting" Version="3.8.0" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="3.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.SpaProxy">
<Version>8.*-*</Version>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\QuickApp.Core\QuickApp.Core.csproj" />
<ProjectReference Include="..\quickapp.client\quickapp.client.esproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\QuickApp.Core\QuickApp.Core.csproj" />
<ProjectReference Include="..\quickapp.client\quickapp.client.esproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>

<ItemGroup>
<None Update="Services\Email\*.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Update="Services\Email\*.template">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
11 changes: 1 addition & 10 deletions QuickApp.Server/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\MSSQLLocalDB;Database=QuickApp;Trusted_Connection=True;TrustServerCertificate=true;MultipleActiveResultSets=true"
},

"https_port": "44350",

"SmtpConfig": {
"Host": "mail.example.com",
"Port": 25,
Expand All @@ -15,13 +13,6 @@
"Password": "YourPassword"
},

"Certificates": {
"OIDC": {
"Path": "Certificates/quickapp.pfx",
"Password": "YourPassword"
}
},

// LogLevel Severity: "Trace", "Debug", "Information", "Warning", "Error", "Critical", "None"
"Logging": {
"PathFormat": "Logs/log-{Date}.log",
Expand Down
9 changes: 7 additions & 2 deletions QuickApp.Server/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"DefaultConnection": "Server=(local);Database=QuickApp;Trusted_Connection=True;TrustServerCertificate=true;MultipleActiveResultSets=true"
},

"https_port": 5001, //Set this for https redirection (e.g. 443)

"SmtpConfig": {
"Host": "mail.example.com",
"Port": 25,
Expand All @@ -15,6 +13,13 @@
"Password": "YourPassword"
},

"OIDC": {
"Certificates": {
"Path": "", // e.g. "Certificates/quickapp.pfx"
"Password": ""
}
},

// LogLevel Severity: "Trace", "Debug", "Information", "Warning", "Error", "Critical", "None"
"Logging": {
"PathFormat": "Logs/log-{Date}.log",
Expand Down
2 changes: 1 addition & 1 deletion quickapp.client/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# QuickappClient

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.0.9.
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.1.2.

## Development server

Expand Down
Loading

0 comments on commit 5f99103

Please sign in to comment.