diff --git a/BTCPayServer.Client/Models/CreateApplicationUserRequest.cs b/BTCPayServer.Client/Models/CreateApplicationUserRequest.cs index 0980f9373..f1e4e29bd 100644 --- a/BTCPayServer.Client/Models/CreateApplicationUserRequest.cs +++ b/BTCPayServer.Client/Models/CreateApplicationUserRequest.cs @@ -26,5 +26,10 @@ namespace BTCPayServer.Client.Models /// Whether this user is an administrator. If left null and there are no admins in the system, the user will be created as an admin. /// public bool? IsAdministrator { get; set; } + + /// + /// Flag to specify if email invitation should be sent to the user. https://github.com/btcpayserver/btcpayserver/issues/6406#issuecomment-2886252217 + /// + public bool? SkipEmailInvite { get; set; } } } diff --git a/BTCPayServer/Controllers/GreenField/GreenfieldUsersController.cs b/BTCPayServer/Controllers/GreenField/GreenfieldUsersController.cs index b389307a0..4acf0ca7f 100644 --- a/BTCPayServer/Controllers/GreenField/GreenfieldUsersController.cs +++ b/BTCPayServer/Controllers/GreenField/GreenfieldUsersController.cs @@ -249,7 +249,7 @@ namespace BTCPayServer.Controllers.Greenfield { var user = await _userManager.GetUserAsync(User); if (user is null) return this.UserNotFound(); - + UploadImageResultModel? upload = null; if (file is null) ModelState.AddModelError(nameof(file), "Invalid file"); @@ -286,7 +286,7 @@ namespace BTCPayServer.Controllers.Greenfield { var user = await _userManager.GetUserAsync(User); if (user is null) return this.UserNotFound(); - + var blob = user.GetBlob() ?? new UserBlob(); if (!string.IsNullOrEmpty(blob.ImageUrl)) { @@ -315,10 +315,10 @@ namespace BTCPayServer.Controllers.Greenfield ModelState.AddModelError(nameof(request.Email), "Email is missing"); if (!MailboxAddressValidator.IsMailboxAddress(request.Email)) ModelState.AddModelError(nameof(request.Email), "Invalid email"); - + if (!ModelState.IsValid) return this.CreateValidationError(ModelState); - + if (User.Identity is null) throw new JsonHttpException(this.StatusCode(401)); var anyAdmin = (await _userManager.GetUsersInRoleAsync(Roles.ServerAdmin)).Any(); @@ -358,6 +358,9 @@ namespace BTCPayServer.Controllers.Greenfield Created = DateTimeOffset.UtcNow, Approved = isAdmin // auto-approve first admin and users created by an admin }; + if (request.SkipEmailInvite == true) + user.RequiresEmailConfirmation = false; + var blob = user.GetBlob() ?? new(); blob.Name = request.Name; blob.ImageUrl = request.ImageUrl;