mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-19 05:33:31 +01:00
6290b0f3bf
* Users list: Cleanups * Policies: Flip registration settings * Policies: Add RequireUserApproval setting * Add approval to user * Require approval on login and for API key * API handling * AccountController cleanups * Test fix * Apply suggestions from code review Co-authored-by: Nicolas Dorier <nicolas.dorier@gmail.com> * Add missing imports * Communicate login requirements to user on account creation * Add login requirements to basic auth handler * Cleanups and test fix * Encapsulate approval logic in user service and log approval changes * Send follow up "Account approved" email Closes #5656. * Add notification for admins * Fix creating a user via the admin view * Update list: Unify flags into status column, add approve action * Adjust "Resend email" wording * Incorporate feedback from code review * Remove duplicate test server policy reset --------- Co-authored-by: Nicolas Dorier <nicolas.dorier@gmail.com>
35 lines
1.5 KiB
C#
35 lines
1.5 KiB
C#
using System.Threading.Tasks;
|
|
using BTCPayServer.Logging;
|
|
using BTCPayServer.Services;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace BTCPayServer
|
|
{
|
|
// All logic that would otherwise be duplicated across solution goes into this utility class
|
|
// ~If~ Once this starts growing out of control, begin extracting action logic classes out of here
|
|
// Also some of logic in here may be result of parallel development of Greenfield API
|
|
// It's much better that we extract those common methods then copy paste and maintain same code across codebase
|
|
internal static class ActionLogicExtensions
|
|
{
|
|
internal static async Task FirstAdminRegistered(this SettingsRepository settingsRepository, PoliciesSettings policies,
|
|
bool updateCheck, bool disableRegistrations, Logs logs)
|
|
{
|
|
if (updateCheck)
|
|
{
|
|
logs.PayServer.LogInformation("First admin created, enabling checks for new versions");
|
|
policies.CheckForNewVersions = updateCheck;
|
|
}
|
|
|
|
if (disableRegistrations)
|
|
{
|
|
// Once the admin user has been created lock subsequent user registrations (needs to be disabled for unit tests that require multiple users).
|
|
logs.PayServer.LogInformation("First admin created, disabling subscription (disable-registration is set to true)");
|
|
policies.LockSubscription = true;
|
|
}
|
|
|
|
if (updateCheck || disableRegistrations)
|
|
await settingsRepository.UpdateSetting(policies);
|
|
}
|
|
}
|
|
}
|