This commit is contained in:
yuanke 2016-08-12 14:13:53 +08:00
parent ded55ca022
commit c307f7769f
2 changed files with 9 additions and 5 deletions

View File

@ -440,14 +440,18 @@ class WechatsController < ActionController::Base
private private
def get_openid_from_code(code) def get_openid_from_code(code)
info = wechat.web_access_token(code)
logger.info "web_access_token!!!!!!!!!!!!"
logger.info info
return 'oCnvgvz8R7QheXE-R9Kkr39j8Ndg' if code =='only-for-test' return 'oCnvgvz8R7QheXE-R9Kkr39j8Ndg' if code =='only-for-test'
openid = session[:wechat_openid] openid = session[:wechat_openid]
unless openid unless openid
if code if code
openid = wechat.web_access_token(code)["openid"] info = wechat.web_access_token(code)
openid =info["openid"]
access_token =info["access_token"]
if access_token
session[:access_token] = access_token
end
# openid = wechat.web_access_token(code)["openid"]
# info = wechat.web_access_token(code) # info = wechat.web_access_token(code)
# logger.info "web_access_token!!!!!!!!!!!!" # logger.info "web_access_token!!!!!!!!!!!!"
# logger.info info # logger.info info

View File

@ -127,7 +127,7 @@ module Wechat
openid: openid, openid: openid,
lang: "zh_CN" lang: "zh_CN"
} }
get 'user_info', params: params, base: OAUTH2_BASE get 'userinfo', params: params, base: OAUTH2_BASE
end end
end end
end end