示例#1
0
        public IActionResult Profile(ProfilePassword pass)
        {
            if (string.IsNullOrEmpty(pass.oldpassword) || string.IsNullOrEmpty(pass.confirmpassword) || string.IsNullOrEmpty(pass.newpassword))
            {
                ViewData["Error"] = "Please fill all fields";
                return(View());
            }
            if (pass.newpassword != pass.confirmpassword)
            {
                ViewData["Error"] = "Passwords Dont Match!";
                return(View());
            }
            var verifyPassword = AdminController.Instance.VerifyPassword(pass.oldpassword, HttpContext.Request.Cookies["XTkCookie"]).Result;

            if (!verifyPassword)
            {
                ViewData["Error"] = "Incorrect Password";
                return(View());
            }
            else
            {
                var saveNewPassword = AdminController.Instance.ChangePassword(pass, HttpContext.Request.Cookies["XTkCookie"]);
                ViewData["Success"] = "Password Changed Successfully!";
                return(View());
            }
        }
示例#2
0
        public async Task <bool> ChangePassword(ProfilePassword pass, string token)
        {
            try
            {
                var tk = token.Split(":");
                var encryptedUsername    = tk[1];
                var decryptedUsername    = TokenHelper.Instance.Decrypt(encryptedUsername);
                var encryptedNewPassword = TokenHelper.Instance.Encrypt(pass.newpassword);
                using (var con = new XinematriXContext())
                {
                    var user = await Task.Run(() => con.WebAdminAuth.Where(p => p.WebAdminUsername == decryptedUsername).FirstOrDefault());

                    user.WebAdminPassword = encryptedNewPassword;
                    await con.SaveChangesAsync();
                }
                return(true);
            }
            catch (Exception x)
            {
                return(false);
            }
        }
示例#3
0
 internal void ClickPasswordChange()
 {
     ProfilePassword.Click();
     Thread.Sleep(1000);
     ChangePassword.Click();
 }