mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 14:04:26 +01:00
Adding flag on Greenfield create user call to skip email invitation
This commit is contained in:
@@ -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.
|
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool? IsAdministrator { get; set; }
|
public bool? IsAdministrator { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Flag to specify if email invitation should be sent to the user. https://github.com/btcpayserver/btcpayserver/issues/6406#issuecomment-2886252217
|
||||||
|
/// </summary>
|
||||||
|
public bool? SkipEmailInvite { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
{
|
{
|
||||||
var user = await _userManager.GetUserAsync(User);
|
var user = await _userManager.GetUserAsync(User);
|
||||||
if (user is null) return this.UserNotFound();
|
if (user is null) return this.UserNotFound();
|
||||||
|
|
||||||
UploadImageResultModel? upload = null;
|
UploadImageResultModel? upload = null;
|
||||||
if (file is null)
|
if (file is null)
|
||||||
ModelState.AddModelError(nameof(file), "Invalid file");
|
ModelState.AddModelError(nameof(file), "Invalid file");
|
||||||
@@ -286,7 +286,7 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
{
|
{
|
||||||
var user = await _userManager.GetUserAsync(User);
|
var user = await _userManager.GetUserAsync(User);
|
||||||
if (user is null) return this.UserNotFound();
|
if (user is null) return this.UserNotFound();
|
||||||
|
|
||||||
var blob = user.GetBlob() ?? new UserBlob();
|
var blob = user.GetBlob() ?? new UserBlob();
|
||||||
if (!string.IsNullOrEmpty(blob.ImageUrl))
|
if (!string.IsNullOrEmpty(blob.ImageUrl))
|
||||||
{
|
{
|
||||||
@@ -315,10 +315,10 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
ModelState.AddModelError(nameof(request.Email), "Email is missing");
|
ModelState.AddModelError(nameof(request.Email), "Email is missing");
|
||||||
if (!MailboxAddressValidator.IsMailboxAddress(request.Email))
|
if (!MailboxAddressValidator.IsMailboxAddress(request.Email))
|
||||||
ModelState.AddModelError(nameof(request.Email), "Invalid email");
|
ModelState.AddModelError(nameof(request.Email), "Invalid email");
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return this.CreateValidationError(ModelState);
|
return this.CreateValidationError(ModelState);
|
||||||
|
|
||||||
if (User.Identity is null)
|
if (User.Identity is null)
|
||||||
throw new JsonHttpException(this.StatusCode(401));
|
throw new JsonHttpException(this.StatusCode(401));
|
||||||
var anyAdmin = (await _userManager.GetUsersInRoleAsync(Roles.ServerAdmin)).Any();
|
var anyAdmin = (await _userManager.GetUsersInRoleAsync(Roles.ServerAdmin)).Any();
|
||||||
@@ -358,6 +358,9 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||||||
Created = DateTimeOffset.UtcNow,
|
Created = DateTimeOffset.UtcNow,
|
||||||
Approved = isAdmin // auto-approve first admin and users created by an admin
|
Approved = isAdmin // auto-approve first admin and users created by an admin
|
||||||
};
|
};
|
||||||
|
if (request.SkipEmailInvite == true)
|
||||||
|
user.RequiresEmailConfirmation = false;
|
||||||
|
|
||||||
var blob = user.GetBlob() ?? new();
|
var blob = user.GetBlob() ?? new();
|
||||||
blob.Name = request.Name;
|
blob.Name = request.Name;
|
||||||
blob.ImageUrl = request.ImageUrl;
|
blob.ImageUrl = request.ImageUrl;
|
||||||
|
|||||||
Reference in New Issue
Block a user