lib/blsm-mp-wx.rb in blsm-mp-wx-0.3.3 vs lib/blsm-mp-wx.rb in blsm-mp-wx-0.3.4
- old
+ new
@@ -371,10 +371,11 @@
else
response_body = response.body
end
res = parse_json(response_body)
+ return res unless res['access_token']
conn = Faraday.new(:url => 'https://api.weixin.qq.com')
response = conn.post do |req|
req.url '/sns/userinfo'
@@ -387,9 +388,11 @@
else
response_body = response.body
end
res = parse_json(response_body)
+ return res unless res['nickname']
+
VdWxUser.find_or_create_by({app_id: app_id, openid: res['openid']}) do |u|
u.update_attributes({nickname: res['nickname'],
sex: res['sex'],
unionid: res['unionid'],
language: res['language'],