修改判断绑定代码

This commit is contained in:
yuanke 2016-08-14 11:59:26 +08:00
parent 9d867aa224
commit ba0d32bd09
2 changed files with 3 additions and 17 deletions

View File

@ -23,22 +23,8 @@ module Mobile
refresh_token = session[:refresh_token]
if access_token.present? && refresh_token.present?
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
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
access_token = refreshinfo["access_token"]
refresh_token = refreshinfo["refresh_token"]
session[:access_token] = access_token

View File

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