From c9546831333c1dbfc0bfa9b9baa5a32d9fcc5a2d Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 5 Oct 2016 22:03:02 -0400 Subject: [PATCH] If no ciphers yet, just save user when changing password/email --- .gitignore | 1 + src/Core/Services/UserService.cs | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 911d23637..a6f1fac81 100644 --- a/.gitignore +++ b/.gitignore @@ -198,3 +198,4 @@ FakesAssemblies/ # Other project.lock.json +*.jfm diff --git a/src/Core/Services/UserService.cs b/src/Core/Services/UserService.cs index 4248a0e6b..209e0c406 100644 --- a/src/Core/Services/UserService.cs +++ b/src/Core/Services/UserService.cs @@ -142,7 +142,16 @@ namespace Bit.Core.Services user.Email = newEmail; user.EmailVerified = true; user.RevisionDate = DateTime.UtcNow; - await _cipherRepository.UpdateUserEmailPasswordAndCiphersAsync(user, ciphers); + + if(ciphers.Any()) + { + await _cipherRepository.UpdateUserEmailPasswordAndCiphersAsync(user, ciphers); + } + else + { + await _userRepository.ReplaceAsync(user); + } + return IdentityResult.Success; } @@ -167,7 +176,15 @@ namespace Bit.Core.Services } user.RevisionDate = DateTime.UtcNow; - await _cipherRepository.UpdateUserEmailPasswordAndCiphersAsync(user, ciphers); + if(ciphers.Any()) + { + await _cipherRepository.UpdateUserEmailPasswordAndCiphersAsync(user, ciphers); + } + else + { + await _userRepository.ReplaceAsync(user); + } + return IdentityResult.Success; }