修改openid路由
This commit is contained in:
parent
a25fe6cef8
commit
1926f0ba53
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue