修改判断绑定代码
This commit is contained in:
parent
9d867aa224
commit
ba0d32bd09
|
@ -23,22 +23,8 @@ module Mobile
|
||||||
refresh_token = session[:refresh_token]
|
refresh_token = session[:refresh_token]
|
||||||
|
|
||||||
if access_token.present? && refresh_token.present?
|
if access_token.present? && refresh_token.present?
|
||||||
begin
|
refreshinfo = Wechat.api.web_refresh_access_token(refresh_token)
|
||||||
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"]
|
access_token = refreshinfo["access_token"]
|
||||||
refresh_token = refreshinfo["refresh_token"]
|
refresh_token = refreshinfo["refresh_token"]
|
||||||
session[:access_token] = access_token
|
session[:access_token] = access_token
|
||||||
|
|
|
@ -470,7 +470,7 @@ class WechatsController < ActionController::Base
|
||||||
|
|
||||||
def user_binded?(openid)
|
def user_binded?(openid)
|
||||||
uw = UserWechat.where(openid: openid).first
|
uw = UserWechat.where(openid: openid).first
|
||||||
if uw.bindtype == 0
|
if uw && uw.bindtype == 0
|
||||||
uw
|
uw
|
||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
|
|
Loading…
Reference in New Issue