<commit_before>var restful = require('./../restful');
var baseUrl = 'https://api.weixin.qq.com/cgi-bin/user/';

function getUrl(type, params) {
  return baseUrl + type + '?' + restful.toParam(params);
}

module.exports = {
  info: function (id, cb) {
    var params = {
      openid: id,
      lang: 'zh-CN'
    };
    var url = getUrl('info', params);
    restful.request(url, null, cb);
  },
  list: function(id, cb) {
      var params = {};
    if (id) {
      params.next_openid = id;
    }
    var url = getUrl('get', params);
    restful.request(url, null, cb);
  }
};<commit_msg>enabled user auth<commit_after>var restful = require('./../restful');
var auth = require('./../auth');
var baseUrl = 'https://api.weixin.qq.com/cgi-bin/user/';

function getUrl(type, params) {
  return baseUrl + type + '?' + restful.toParam(params);
}

var user = {
  info: function (id, cb) {
    var params = {
      openid: id,
      lang: 'zh-CN'
    };
    var url = getUrl('info', params);
    restful.request(url, null, cb);
  },
  list: function(id, cb) {
    var params = {};
    if (id) {
      params.next_openid = id;
    }
    var url = getUrl('get', params);
    restful.request(url, null, cb);
  },
  oauth: {
    buildUrl: function(params) {
      var oauthUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize';
      return oauthUrl + '?' + restful.toParam(params, true) + '#wechat_redirect';
    },
    tokenize: function(params, cb) {
      var oauthUrl = 'https://api.weixin.qq.com/sns/oauth2/access_token';

      var url = oauthUrl + '?' + restful.toParam(params) + '#wechat_redirect';
      restful.request(url, null, cb);
    },
    authorize: function(code, state, cb) {
      var baseUrl = 'https://api.weixin.qq.com/sns/oauth2/access_token';
      var params = {
        appid: auth.appId,
        secret: auth.appSecret,
        grant_type: 'authorization_code',
        code: code
      };
      user.oauth.tokenize(params, function(error, json) {
        console.log(error);
        console.log(json);
        if (error) {
          cb(true);
        } else {
          cb(false, json);
        }

      });
    }

  }
};

module.exports =  user;
{'fraction_non_alphanumeric': 0.1720479704797048, 'fraction_numerical': 0.0013837638376383763, 'mean_word_length': 2.4319620253164556, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7509939', 'n_tokens_mistral': 776, 'n_tokens_neox': 770, 'n_words': 155}