修改openid路由
This commit is contained in:
parent
a25fe6cef8
commit
1926f0ba53
|
@ -211,13 +211,6 @@ class WechatsController < ActionController::Base
|
||||||
render 'wechats/login', layout: 'base_wechat'
|
render 'wechats/login', layout: 'base_wechat'
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_openid
|
|
||||||
code = params[:code]
|
|
||||||
openid = get_openid_from_code(code)
|
|
||||||
render :text => {openid: openid}.to_json
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def get_openid_from_code(code)
|
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"
|
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
|
collection do
|
||||||
get :login
|
get :login
|
||||||
post :bind
|
post :bind
|
||||||
get :get_open_id
|
post :get_open_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,9 @@ $(function(){
|
||||||
}
|
}
|
||||||
var code = getUrlParam("code");
|
var code = getUrlParam("code");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/wechat/get_open_id?code='+code,
|
url: '/wechat/get_open_id',
|
||||||
type: 'get',
|
data: {code: code},
|
||||||
|
type: 'post',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(data){
|
success: function(data){
|
||||||
g_openid = data.openid;
|
g_openid = data.openid;
|
||||||
|
|
Loading…
Reference in New Issue