Fix: Setting the password of a new created user via API shouldn't be required (Close #4534) (#4647)

This commit is contained in:
Nicolas Dorier
2023-02-15 17:11:39 +09:00
committed by GitHub
parent b99253ff47
commit fc14f418cb
3 changed files with 3 additions and 15 deletions

View File

@@ -655,15 +655,8 @@ namespace BTCPayServer.Tests
tester.PayTester.DisableRegistration = true;
await tester.StartAsync();
var unauthClient = new BTCPayServerClient(tester.PayTester.ServerUri);
await AssertValidationError(new[] { "Email", "Password" },
await AssertValidationError(new[] { "Email" },
async () => await unauthClient.CreateUser(new CreateApplicationUserRequest()));
await AssertValidationError(new[] { "Password" },
async () => await unauthClient.CreateUser(
new CreateApplicationUserRequest() { Email = "test@gmail.com" }));
// Pass too simple
await AssertValidationError(new[] { "Password" },
async () => await unauthClient.CreateUser(
new CreateApplicationUserRequest() { Email = "test3@gmail.com", Password = "a" }));
// We have no admin, so it should work
var user1 = await unauthClient.CreateUser(
@@ -1347,10 +1340,6 @@ namespace BTCPayServer.Tests
Password = Guid.NewGuid().ToString()
}));
await AssertValidationError(new[] { "Password" }, async () =>
await clientServer.CreateUser(
new CreateApplicationUserRequest() { Email = $"{Guid.NewGuid()}@g.com", }));
await AssertValidationError(new[] { "Email" }, async () =>
await clientServer.CreateUser(
new CreateApplicationUserRequest() { Password = Guid.NewGuid().ToString() }));

View File

@@ -124,8 +124,6 @@ namespace BTCPayServer.Controllers.Greenfield
{
ModelState.AddModelError(nameof(request.Email), "Invalid email");
}
if (request.Password is null)
ModelState.AddModelError(nameof(request.Password), "Password is missing");
if (!ModelState.IsValid)
{
return this.CreateValidationError(ModelState);

View File

@@ -108,7 +108,8 @@
},
"password": {
"type": "string",
"description": "The password of the new user"
"description": "The password of the new user (if no password is set, an email will be sent to the user requiring him to set the password)",
"nullable": true
},
"isAdministrator": {
"type": "boolean",