修改微信BUG

This commit is contained in:
yuanke 2016-08-14 11:50:31 +08:00
parent 3be75c8633
commit 9d867aa224
2 changed files with 20 additions and 2 deletions

View File

@ -23,7 +23,21 @@ module Mobile
refresh_token = session[:refresh_token]
if access_token.present? && refresh_token.present?
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
begin
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
rescue
info = wechat.web_access_token(session[:wechat_code])
openid =info["openid"]
access_token =info["access_token"]
if access_token
session[:access_token] = access_token
end
refresh_token = info["refresh_token"]
if refresh_token
session[:refresh_token] = refresh_token
end
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
end
access_token = refreshinfo["access_token"]
refresh_token = refreshinfo["refresh_token"]

View File

@ -470,7 +470,11 @@ class WechatsController < ActionController::Base
def user_binded?(openid)
uw = UserWechat.where(openid: openid).first
uw && uw.bindtype == 0
if uw.bindtype == 0
uw
else
nil
end
end
def current_url