示例#1
0
        public APIResult ChangePassword([FromBody] ChangePasswordArgsModel args)
        {
            var memberId = GetMemberId();
            var model    = memberDb.QueryMember()
                           .Where(m => m.Id == memberId)
                           .FirstOrDefault();

            if (model == null)
            {
                throw new Exception("数据库记录不存在");
            }
            if (model.Password != MemberPasswordToMD5(args.Password))
            {
                throw new Exception("原密码不正确");
            }
            if (args.NewPassword != args.ConfirmPassword)
            {
                throw new Exception("两次输入的密码不相等");
            }

            model.Password = MemberPasswordToMD5(args.NewPassword);
            memberDb.SaveChanges();

            return(Success());
        }
示例#2
0
        public APIResult ChangePassword([FromBody] ChangePasswordArgsModel args)
        {
            if (!args.shopId.HasValue)
            {
                throw new Exception("ShopId不能为空");
            }
            var server = new ShopMemberServer(db, args.shopId.Value, GetMemberId());

            server.ChangePassword(args.OldPWD, args.NewPWD);
            db.SaveChanges();
            return(Success());
        }