weixin_login
guange 9 years ago
parent 762ca9c3cb
commit f40794282f

@ -14,7 +14,8 @@ module Mobile
post 'wxbind' do post 'wxbind' do
openid = params[:openid] openid = params[:openid]
raise "无法获取到openid,请在微信中打开本页面" unless openid raise "无法获取到openid,请在微信中打开本页面" unless openid
raise "此微信号已绑定用户, 不能重复绑定" if UserWechat.where(openid: openid).first uw = UserWechat.where(openid: openid).first
raise "此微信号已绑定用户(#{uw.user.login}), 不能重复绑定" if uw
user, last_login_on = User.try_to_login(params[:login], params[:password]) user, last_login_on = User.try_to_login(params[:login], params[:password])
raise "用户名或密码错误,请重新输入" unless user raise "用户名或密码错误,请重新输入" unless user
@ -26,8 +27,8 @@ module Mobile
openid: openid, openid: openid,
user: user user: user
) )
ws = WechatService.new # ws = WechatService.new
ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台", user.login, format_time(Time.now)) # ws.binding_succ_notice(user.id, "您已成功绑定Trustie平台", user.login, format_time(Time.now))
present status: 0 present status: 0
present message: '绑定成功' present message: '绑定成功'
end end

Loading…
Cancel
Save