<commit_before>exports.init = function (app) {
	var wechat_cfg = require('../config/wechat.cfg');
	var http = require('http');
	var https = require('https');
	var cache = require('memory-cache');
	var sha1 = require('sha1'); //签名算法
	//var url = require('url');
	var signature = require('../sign/signature');
	var url = require('url');
	var appID = wechat_cfg.appid;
	var appSecret = wechat_cfg.secret;

	var getToken = require('../sign/token').getToken;

	
	app.get('/',function(req,res){
		//var url = req.protocol + '://' + req.host + req.path;
		var url = req.protocol + '://' + req.host + req.originalUrl; //获取当前url
		console.log(req);
		signature.sign(url,function(signatureMap){
			signatureMap.appId = wechat_cfg.appid;
			res.render('index',{"signatureMap":signatureMap});
		});
	});

	app.get('/auth',function(req,res){
		var token = "";
		var tokenResult = getToken(wechat_cfg.accessTokenUrl);
		console.log(tokenResult);
    	token = tokenResult.access_token;

		//var url = req.protocol + '://' + req.host + req.path;
		var myurl = req.protocol + '://' + req.host + req.originalUrl; //获取当前url
		console.log(myurl);
		var code = url.parse(req.url,true).query.code;
        var link = 'https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token='+token+'&code='+code;
        console.log(new Date()+' and the code is '+code+' Now getting the Number...');
        console.log(link);
        var res = https.get(link, function(data){
            var bodyChunks = '';
            data.on('data',function(chunk){
                bodyChunks += chunk;
            });
            data.on('end',function(){
                var body = JSON.parse(bodyChunks);
                console.log(body);
                if (body.UserId) {
                    req.session.No = body.UserId;
                    console.log(req.session.No);
                    signature.sign(url, function(signatureMap){
						signatureMap.appId = wechat_cfg.appid;
						signatureMap.UserId = body.UserId;
						res.render('index',{"signatureMap":signatureMap});
					});
                }else{
                    console.dir(body);
                }
            });
		});
    });

};<commit_msg>commit 19<commit_after>exports.init = function (app) {
	var wechat_cfg = require('../config/wechat.cfg');
	var http = require('http');
	var https = require('https');
	var cache = require('memory-cache');
	var sha1 = require('sha1'); //签名算法
	//var url = require('url');
	var signature = require('../sign/signature');
	var url = require('url');
	var appID = wechat_cfg.appid;
	var appSecret = wechat_cfg.secret;

	var getToken = require('../sign/token').getToken;

	
	app.get('/',function(req,res){
		//var url = req.protocol + '://' + req.host + req.path;
		var url = req.protocol + '://' + req.host + req.originalUrl; //获取当前url
		console.log(req);
		signature.sign(url,function(signatureMap){
			signatureMap.appId = wechat_cfg.appid;
			res.render('index',{"signatureMap":signatureMap});
		});
	});

	app.get('/auth',function(req,res){
		getToken(wechat_cfg.accessTokenUrl).then(function(res){
    		var token = res.access_token;
    		console.log(token);
    		var code = url.parse(req.url,true).query.code;
	        var link = 'https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token='+token+'&code='+code;
	        console.log(new Date()+' and the code is '+code+' Now getting the Number...');
	        console.log(link);
	        var res = https.get(link, function(data){
	            var bodyChunks = '';
	            data.on('data',function(chunk){
	                bodyChunks += chunk;
	            });
	            data.on('end',function(){
	                var body = JSON.parse(bodyChunks);
	                console.log(body);
	                if (body.UserId) {
	                    req.session.No = body.UserId;
	                    console.log(req.session.No);
	                    signature.sign(url, function(signatureMap){
							signatureMap.appId = wechat_cfg.appid;
							signatureMap.UserId = body.UserId;
							res.render('index',{"signatureMap":signatureMap});
						});
	                }else{
	                    console.dir(body);
	                }
	            });
			});

    	});
				
    });

};
{'fraction_non_alphanumeric': 0.1702632202987906, 'fraction_numerical': 0.0014228124258951862, 'mean_word_length': 2.3529411764705883, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2045166', 'n_tokens_mistral': 1442, 'n_tokens_neox': 1333, 'n_words': 228}