public IActionResult Validate(LoginIndexViewModel model) { var repository = VaultRepositoryFactory.CreateInstance(); if (ModelState.IsValid) { using (var masterPasswordSecure = SecureStringConverter.ToSecureString(model.MasterPassword)) { if (repository.IsPasswordValid(model.SelectedVault, masterPasswordSecure)) { this.SessionContext.SetCurrentVaultName(model.SelectedVault); this.SessionContext.SetMasterPassword(masterPasswordSecure); return(RedirectToAction("Index", "VaultExplorer")); } else { ModelState.AddModelError(nameof(model.MasterPassword), StringResources.IncorrectPassword); } } } model.VaultNames = repository.GetAllVaultNames(); return(View("Index", model)); }
public SecureString FromByteArray(byte[] data) { return(SecureStringConverter.ToSecureString(Encoding.UTF8.GetString(Cryptographer.Decrypt(data, EncryptionKey)))); }