コード例 #1
0
        public bool ChangePassword(Guid userId, string oldPassword, string newPassword)
        {
            var res = false;

            var detail = _UserCollection.GetById(userId);

            if (detail != null)
            {
                if (Encrypting.BcryptVerify(oldPassword, detail.Password))
                {
                    // Change mật khẩu
                    if (_UserCollection.ChangePassword(new UserFilter()
                    {
                        Id = userId
                    }, Encrypting.Bcrypt(newPassword)) > 0)
                    {
                        res = true;
                    }
                    else
                    {
                        _Setting.Message.SetMessage("Không thể cập nhật thông tin mật khẩu!");
                    };
                }
                else
                {
                    _Setting.Message.SetMessage("Mật khẩu hiện tại không đúng!");
                }
            }
            else
            {
                _Setting.Message.SetMessage("Không tìm thấy thông tin người dùng!");
            }

            return(res);
        }