diff --git a/cli/SimpleModule.Cli/Commands/Install/InstallCommand.cs b/cli/SimpleModule.Cli/Commands/Install/InstallCommand.cs index a5f96092..f9e3da8a 100644 --- a/cli/SimpleModule.Cli/Commands/Install/InstallCommand.cs +++ b/cli/SimpleModule.Cli/Commands/Install/InstallCommand.cs @@ -31,23 +31,24 @@ public override int Execute(CommandContext context, InstallSettings settings) $"Installing [green]{Markup.Escape(settings.PackageId)}[/] into [blue]{Markup.Escape(Path.GetFileName(hostCsproj))}[/]..." ); - var args = $"add \"{hostCsproj}\" package {settings.PackageId}"; + var psi = new ProcessStartInfo + { + FileName = "dotnet", + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + }; + psi.ArgumentList.Add("add"); + psi.ArgumentList.Add(hostCsproj); + psi.ArgumentList.Add("package"); + psi.ArgumentList.Add(settings.PackageId); if (!string.IsNullOrWhiteSpace(settings.Version)) { - args += $" --version {settings.Version}"; + psi.ArgumentList.Add("--version"); + psi.ArgumentList.Add(settings.Version); } - using var process = new Process - { - StartInfo = new ProcessStartInfo - { - FileName = "dotnet", - Arguments = args, - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, - }, - }; + using var process = new Process { StartInfo = psi }; process.Start(); var outputTask = process.StandardOutput.ReadToEndAsync(); diff --git a/framework/SimpleModule.Blazor/Components/DarkModeScript.razor b/framework/SimpleModule.Blazor/Components/DarkModeScript.razor index 81166e64..857ebe74 100644 --- a/framework/SimpleModule.Blazor/Components/DarkModeScript.razor +++ b/framework/SimpleModule.Blazor/Components/DarkModeScript.razor @@ -1,4 +1,7 @@ - - diff --git a/modules/OpenIddict/src/SimpleModule.OpenIddict/Endpoints/Connect/TokenEndpoint.cs b/modules/OpenIddict/src/SimpleModule.OpenIddict/Endpoints/Connect/TokenEndpoint.cs index 0312ed62..2a11a50c 100644 --- a/modules/OpenIddict/src/SimpleModule.OpenIddict/Endpoints/Connect/TokenEndpoint.cs +++ b/modules/OpenIddict/src/SimpleModule.OpenIddict/Endpoints/Connect/TokenEndpoint.cs @@ -80,12 +80,7 @@ private static async Task HandleAsync(HttpContext context) identity.AddClaim("permission", permission); } - identity.SetScopes( - Scopes.OpenId, - Scopes.Profile, - Scopes.Email, - AuthConstants.RolesScope - ); + identity.SetScopes(Scopes.OpenId, Scopes.Profile, Scopes.Email, AuthConstants.RolesScope); foreach (var claim in identity.Claims) { diff --git a/modules/OpenIddict/src/SimpleModule.OpenIddict/Services/OpenIddictSeedService.cs b/modules/OpenIddict/src/SimpleModule.OpenIddict/Services/OpenIddictSeedService.cs index 3d1c9ac7..77334626 100644 --- a/modules/OpenIddict/src/SimpleModule.OpenIddict/Services/OpenIddictSeedService.cs +++ b/modules/OpenIddict/src/SimpleModule.OpenIddict/Services/OpenIddictSeedService.cs @@ -82,9 +82,7 @@ is not null // Allow password grant in Development for load testing (k6, etc.) if (configuration.GetValue("OpenIddict:AllowPasswordGrant")) { - descriptor.Permissions.Add( - OpenIddictConstants.Permissions.GrantTypes.Password - ); + descriptor.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.Password); } // Allow additional redirect URIs from configuration diff --git a/modules/Users/src/SimpleModule.Users/Services/UserSeedService.cs b/modules/Users/src/SimpleModule.Users/Services/UserSeedService.cs index c20bafaa..e42b05b2 100644 --- a/modules/Users/src/SimpleModule.Users/Services/UserSeedService.cs +++ b/modules/Users/src/SimpleModule.Users/Services/UserSeedService.cs @@ -11,6 +11,7 @@ namespace SimpleModule.Users.Services; public partial class UserSeedService( IServiceProvider serviceProvider, IConfiguration configuration, + IHostEnvironment environment, ILogger logger ) : IHostedService { @@ -116,6 +117,8 @@ string role }; var password = configuration[passwordConfigKey] ?? defaultPassword; + if (password == defaultPassword && !environment.IsDevelopment()) + LogDefaultPasswordWarning(logger, email, passwordConfigKey); var result = await userManager.CreateAsync(user, password); if (result.Succeeded) { @@ -136,6 +139,16 @@ string role [LoggerMessage(Level = LogLevel.Information, Message = "Seeding user: {Email}")] private static partial void LogSeedingUser(ILogger logger, string email); + [LoggerMessage( + Level = LogLevel.Warning, + Message = "Seeding {Email} with default password. Set '{ConfigKey}' in configuration before deploying to production." + )] + private static partial void LogDefaultPasswordWarning( + ILogger logger, + string email, + string configKey + ); + [LoggerMessage(Level = LogLevel.Error, Message = "Seed error: {ErrorDescription}")] private static partial void LogSeedError(ILogger logger, string errorDescription); } diff --git a/template/SimpleModule.Host/ClientApp/app.tsx b/template/SimpleModule.Host/ClientApp/app.tsx index d8e6dbc9..13948823 100644 --- a/template/SimpleModule.Host/ClientApp/app.tsx +++ b/template/SimpleModule.Host/ClientApp/app.tsx @@ -119,13 +119,14 @@ function showErrorToast(message: string) {

Error

-

${message.replace(/[<>"'&]/g, (c) => `&#${c.charCodeAt(0)};`)}

+

`; + container.querySelector('p.opacity-90')!.textContent = message; container.querySelector('button')?.addEventListener('click', () => container.remove()); document.body.appendChild(container); setTimeout(() => container.remove(), 8000);