public async Task <IActionResult> SignupAsync([FromBody] UserModel user)
        {
            user.Password = _encryptorDecryptor.Encrypt(user.Password);
            var result = await _userRepository.InsertUpdateUserAsync(user);

            if (result > 0)
            {
                return(new ObjectResult(result));
            }
            else
            {
                return(BadRequest("There is some issue while creating profile. Please try again later"));
            }
        }
Exemple #2
0
        public void EncryptDecryptTests(string plainText)
        {
            var encryptedResult = _encryptorDecryptor.Encrypt(plainText);
            var decryptedResult = _encryptorDecryptor.Decrypt(encryptedResult);

            Assert.AreEqual(plainText, decryptedResult);
        }
Exemple #3
0
        /// <summary>
        /// Performs encoding transformation for each <c>XmlElement</c> of <c>App.config</c> where <c>Encode</c> transform is applied for.
        /// </summary>
        protected override void Apply()
        {
            //If target node has no attributes - skip the transform:
            if (TargetNode.Attributes == null)
            {
                return;
            }

            //Getting list of passed XPath arguments to this Encode instance:
            var encodeXPathArguments = new List <string>();

            if (Arguments != null)
            {
                encodeXPathArguments.AddRange(Arguments);
            }

            //Adding DefaultAttributeName to XPath arguments if it's not present:
            if (!encodeXPathArguments.Contains(DefaultAttributeName))
            {
                encodeXPathArguments.Add(DefaultAttributeName);
            }

            //Looping thru TargetNodes
            foreach (var targetNode in TargetNodes.OfType <XmlElement>())
            {
                //For each TargetNode looping thru encodeXPathArguments
                foreach (var arg in encodeXPathArguments)
                {
                    //Getting TargetNode.XmlNode by XPath arg:
                    var destinationNode = targetNode.SelectSingleNode(arg);

                    if (destinationNode == null)
                    {
                        continue;
                    }

                    //TransformNode.XmlNode by XPath arg:
                    var applyTransformNode = TransformNode.SelectSingleNode(arg);

                    //Determine which XmlNode.InnerText to encode:
                    string valueToEncode =
                        applyTransformNode == null || string.IsNullOrEmpty(applyTransformNode.InnerText)
                            ? destinationNode.InnerText     //Getting default destination XmlNode.InnerText
                            : applyTransformNode.InnerText; //Getting XmlNode.InnerText specified in App.config transformer

                    if (string.IsNullOrEmpty(valueToEncode))
                    {
                        continue;
                    }

                    //If valueToEncode is OK - then encrypt it and assign to destination XmlNode.InnerText:
                    destinationNode.InnerText = _encryptorDecryptor.Encrypt(valueToEncode);
                }
            }
        }