From 1926f0ba533682bdcb98eb1ff5aaa7a78c0ae69f Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 2 Apr 2016 07:49:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9openid=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/wechats_controller.rb | 7 ------- config/routes.rb | 2 +- public/javascripts/wechat/auth.js | 5 +++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index ed890d1e1..8863043a5 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -211,13 +211,6 @@ class WechatsController < ActionController::Base render 'wechats/login', layout: 'base_wechat' end - def get_openid - code = params[:code] - openid = get_openid_from_code(code) - render :text => {openid: openid}.to_json - end - - private def get_openid_from_code(code) url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=#{Wechat.config.appid}&secret=#{Wechat.config.secret}&code=#{code}&grant_type=authorization_code" diff --git a/config/routes.rb b/config/routes.rb index 2313088cc..327c6af8d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1165,7 +1165,7 @@ RedmineApp::Application.routes.draw do collection do get :login post :bind - get :get_open_id + post :get_open_id end end diff --git a/public/javascripts/wechat/auth.js b/public/javascripts/wechat/auth.js index 44c90c836..e2f8424d4 100644 --- a/public/javascripts/wechat/auth.js +++ b/public/javascripts/wechat/auth.js @@ -20,8 +20,9 @@ $(function(){ } var code = getUrlParam("code"); $.ajax({ - url: '/wechat/get_open_id?code='+code, - type: 'get', + url: '/wechat/get_open_id', + data: {code: code}, + type: 'post', dataType: 'json', success: function(data){ g_openid = data.openid;