diff --git a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt index bc76f5131f4..5501bb0deb9 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryImpl.kt @@ -1302,7 +1302,7 @@ class AuthRepositoryImpl( .sendVerificationEmail( SendVerificationEmailRequestJson( email = email, - name = name, + name = name.takeUnless { it.isBlank() }, receiveMarketingEmails = receiveMarketingEmails, ), ) diff --git a/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt b/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt index 944138f6e6f..72b32e01fc4 100644 --- a/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt +++ b/app/src/test/java/com/x8bit/bitwarden/data/auth/repository/AuthRepositoryTest.kt @@ -6111,6 +6111,29 @@ class AuthRepositoryTest { ) } + @Test + fun `sendVerificationEmail with empty name should use null and return success`() = runTest { + coEvery { + identityService.sendVerificationEmail( + SendVerificationEmailRequestJson( + email = EMAIL, + name = null, + receiveMarketingEmails = true, + ), + ) + } returns EMAIL_VERIFICATION_TOKEN.asSuccess() + + val result = repository.sendVerificationEmail( + email = EMAIL, + name = "", + receiveMarketingEmails = true, + ) + assertEquals( + SendVerificationEmailResult.Success(EMAIL_VERIFICATION_TOKEN), + result, + ) + } + @Test fun `sendVerificationEmail failure should return error`() = runTest { coEvery {