Exemple #1
0
        public async Task <bool> VerifyUserToken(string userEmail, Guid transactionID, string token)
        {
            VerificationInput verifInputs = new VerificationInput();

            verifInputs.TransactionIdentifier = transactionID;
            verifInputs.TransactionToken      = token;

            bool verificationresult = await authentication.Verify(verifInputs);

            return(verificationresult);
        }
        public async Task <bool> Verify(VerificationInput verifInputs)
        {
            TwoStepAuth          auth        = new TwoStepAuth();
            EncryptionDecryption verifyToken = auth.GetEncryptionDecryption;

            //string filepath = "\\TransactFiles\\" + verifInputs.TransactionIdentifier + ".txt";

            string filepath = "/local/temp/" + verifInputs.TransactionIdentifier + ".txt";

            DateTime fileCreationDate = File.GetCreationTime(filepath);

            if (DateTime.Now.Subtract(fileCreationDate).TotalSeconds < 600)
            {
                if (File.Exists(filepath))
                {
                    var fileText = await File.ReadAllTextAsync(filepath);

                    if (!string.IsNullOrEmpty(fileText))
                    {
                        string decrypted = verifyToken.DecryptText(fileText.Trim(), "encryptionKey");

                        File.Delete(filepath);
                        if (decrypted == verifInputs.TransactionToken)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        File.Delete(filepath);
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }