mirror of
https://github.com/bitwarden/server.git
synced 2025-01-08 19:47:44 +01:00
[EC-1032] if name is Empty, set to null before saving (#2619)
This commit is contained in:
parent
cb1ba50ce2
commit
64c15ed8cd
@ -178,6 +178,12 @@ public class UserService : UserManager<User>, IUserService, IDisposable
|
||||
throw new ApplicationException("Use register method to create a new user.");
|
||||
}
|
||||
|
||||
// if the name is empty, set it to null
|
||||
if (String.Equals(user.Name, String.Empty))
|
||||
{
|
||||
user.Name = null;
|
||||
}
|
||||
|
||||
user.RevisionDate = user.AccountRevisionDate = DateTime.UtcNow;
|
||||
await _userRepository.ReplaceAsync(user);
|
||||
|
||||
|
@ -19,6 +19,14 @@ namespace Bit.Core.Test.Services;
|
||||
[SutProviderCustomize]
|
||||
public class UserServiceTests
|
||||
{
|
||||
[Theory, BitAutoData]
|
||||
public async Task SaveUserAsync_SetsNameToNull_WhenNameIsEmpty(SutProvider<UserService> sutProvider, User user)
|
||||
{
|
||||
user.Name = string.Empty;
|
||||
await sutProvider.Sut.SaveUserAsync(user);
|
||||
Assert.Null(user.Name);
|
||||
}
|
||||
|
||||
[Theory, BitAutoData]
|
||||
public async Task UpdateLicenseAsync_Success(SutProvider<UserService> sutProvider,
|
||||
User user, UserLicense userLicense)
|
||||
|
Loading…
Reference in New Issue
Block a user