Ejemplo n.º 1
0
        public IActionResult ResetPassword(User post)
        {
            var userId = HttpContext.User.Claims.First(x => x.Type.Equals(ClaimTypes.Sid)).Value;
            var user   = _context.User.First(x => x.Id.Equals(Convert.ToInt32(userId)));

            user.Password = _dataProtectionService.ToMd5(post.Password);
            _context.User.Update(user);
            _context.SaveChanges();
            return(RedirectToAction("Account"));
        }
Ejemplo n.º 2
0
        public IActionResult CreateAdminAccount(User user)
        {
            try
            {
                user.Role     = "admin";
                user.Password = _dataProtectionService.ToMd5(user.Password);
                _context.User.Add(user);
                _context.SaveChanges();
                return(RedirectToAction("Admin", "Dashboard"));
            }
            catch (Exception e)
            {
                ViewBag.error = e.Message;
            }

            return(View());
        }