public virtual async Task <ValidationResult> PreProcessAsync(string id)
        {
            var secret = await _secretStore.GetAsync(id);

            if (secret == null)
            {
                var notFoundResult = new ValidationResult(false)
                {
                    Error = "Invalid ID",
                    ValidationPointOfFailure = "PreProcess"
                };
                _decryptFailedEventArgs.ValidationResult = notFoundResult;
                _logger.LogDebug("Decryption pre processing invalid");
                _context.OnPreValidationFailed?.Invoke(this, _decryptFailedEventArgs);
                return(notFoundResult);
            }
            Secret = secret;

            ValidationResult result = ValidateSecret(ValidationStage.AfterGet);

            _decryptFailedEventArgs.ValidationResult = result;
            if (!result.IsValid)
            {
                _logger.LogDebug("Decryption pre processing invalid");
                _context.OnPreValidationFailed?.Invoke(this, _decryptFailedEventArgs);
            }
            return(result);
        }
Example #2
0
        public async Task <IActionResult> Delete(string k)
        {
            var email = User.FindFirstValue(ClaimTypes.Email);

            var secret = await _secretStore.GetAsync(k);

            if (!string.IsNullOrEmpty(email) && secret?.CreatedBy == email)
            {
                await _secretStore.DeleteAsync(k);
            }

            return(RedirectToAction("Index", new{ deleted = k }));
        }