Esempio n. 1
0
        public IActionResult ForgotPassword([Bind("emailAddress, password")] ForgotPassword model)
        {
            if (ModelState.IsValid)
            {
                var user = db.ProfileData.Where(e => e.Email == model.emailAddress).FirstOrDefault();
                if (user != null)
                {
                    string token          = TokenProviderService.GenerateToken();
                    var    salt           = db.AccountData.Where(e => e.ProfileId == user.Id).FirstOrDefault();
                    string encryptedToken = EncryptionDecryptionService.Encrypt(token, user.Email, salt.Salt);
                    PasswordForgottenEmail.SendPasswordForgottenEmail(user, encryptedToken, configuration);
                    TempData["Email"] = model.emailAddress;

                    return(RedirectToAction("ForgotPasswordConfirmation", "ForgotPassword"));
                }
                else
                {
                    TempData["Email"] = model.emailAddress;
                    return(RedirectToAction("ForgotPasswordConfirmation", "ForgotPassword"));
                }
            }
            else
            {
                return(View());
            }
        }
        public void GenerateEncryptedString()
        {
            string unEncryptedString = "63fu6929r40w";
            string email             = "*****@*****.**";
            string salt = "5574m5w==";

            var encryptedString = EncryptionDecryptionService.Encrypt(unEncryptedString, email, salt);

            Assert.IsNotNull(encryptedString);
        }