Exemplo n.º 1
0
        public IActionResult ChangePassword([FromBody] PasswordQO pas)
        {
            var userId  = Utils.GetCurrentUserId(User);
            var success = _userService.ChangePassword(userId, pas);

            if (success)
            {
                return(Ok(new { msg = "修改密码成功" }));
            }
            return(NotFound(new { msg = "原密码错误" }));
        }
Exemplo n.º 2
0
        public bool ChangePassword(long userId, PasswordQO pas)
        {
            var pre  = pas.PrePassword;
            var user = _context.Users.Find(userId);

            if (pre != user.Password)
            {
                return(false);
            }
            user.Password = pas.NewPassword;
            _context.SaveChanges();
            return(true);
        }