绑定认证接口 bind

chenlw_dev
guange 10 years ago
parent 0b1b8a4fcd
commit 527b695fab

@ -125,10 +125,12 @@ class WechatsController < ActionController::Base
end
else
openid = request[:FromUserName]
puts wechat.user(request[:openid])
attrs = wechat.user(openid)
UserWechat.delete_all(openid: openid)
uw = UserWechat.create!(attrs)
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } }
request.reply.news(news) do |article, n, index| # article is return object
article.item title: "#{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo1.png', url: login_wechat_url
article.item title: "#{n[:title]}", description: n[:content], pic_url: 'https://www.trustie.net/images/trustie_logo1.png', url: login_wechat_url(openid: uw.id)
end
end
end
@ -140,7 +142,7 @@ class WechatsController < ActionController::Base
raise "用户名或密码错误,请重新登录" unless user
#补全用户信息
user.user_wechat = UserWechat.new(openid: params[:openid])
user.user_wechat = UserWechat.find_by_id(params[:openid])
user.save!
rescue Exception=>e
@wechat_bind_errors = e.message

Loading…
Cancel
Save