public async Task <IActionResult> GetBookingHistory(string userEmail) { ModelState.Clear(); var bookingHistory = await _shoppingService.FetchAllOrders(_decryption.DecryptText(userEmail, ATMConstants.emailEncKey)); VmBookinglist bookings = new VmBookinglist() { Bookings = bookingHistory }; return(View(bookings)); }
private async Task <SmtpClient> EmailConnection(string encryptedKey) { try { SmtpClient client = new SmtpClient("smtp.gmail.com", 587); EncryptionDecryption encryption = EncryptionDecryption.CreateInstance(); if (!string.IsNullOrEmpty(encryptedKey)) { NetworkKeyDTO creds = JsonConvert.DeserializeObject <NetworkKeyDTO>(encryptedKey); client.Credentials = new NetworkCredential(encryption.DecryptText(creds.EncryptedUserName, creds.EncryptedUserMessage), encryption.DecryptText(creds.EncryptedKey, creds.EncryptedMessage)); } return(client); } catch (Exception ep) { Console.WriteLine("failed to send email with the following error:"); Console.WriteLine(ep.Message); throw ep; } }
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); } }
public async Task <VmUser> ValidateUserLogin(VmUser userLogin) { VmUser vUser = null; if (!string.IsNullOrEmpty(userLogin.UserEmail) && !string.IsNullOrEmpty(userLogin.UserEncyryptedKey)) { var userDetails = await _dbContext.User.AsNoTracking().Where(x => x.user_email == userLogin.UserEmail).FirstOrDefaultAsync(); if (userDetails != null) { var masterKey = userDetails.user_email.Substring(2, 4); var message = _encryption.DecryptText(userDetails.user_encryptedmessage, masterKey); var newMessage = _encryption.EncryptText(userLogin.UserEncyryptedKey, message); var result = _encryption.CompareStrings(userDetails.user_encryptedkey, newMessage, message); if (result) { vUser = new VmUser(userDetails); vUser.DecryptedUserEmail = vUser.UserEmail; vUser.UserEmail = _encryption.EncryptText(vUser.DecryptedUserEmail, ATMConstants.emailEncKey); return(vUser); } else { vUser = new VmUser(); vUser.Message = "Invalid email/password"; } } else { vUser = new VmUser(); vUser.Message = "User not found"; } } else { vUser = new VmUser(); vUser.Message = "Invalid email/password"; } return(vUser); }