From d384010d0006b2a364cd444f6a11186612811051 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 21 Feb 2020 22:15:43 +0800 Subject: [PATCH] =?UTF-8?q?qq=E7=BB=91=E5=AE=9A=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bind_users_controller.rb | 40 +++++++++++++++--------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/app/controllers/bind_users_controller.rb b/app/controllers/bind_users_controller.rb index e614322e8..329ade866 100644 --- a/app/controllers/bind_users_controller.rb +++ b/app/controllers/bind_users_controller.rb @@ -4,20 +4,32 @@ class BindUsersController < ApplicationController def create # user = CreateBindUserService.call(create_params) # - - tip_exception '系统错误' if session[:unionid].blank? - - bind_user = User.try_to_login(params[:username], params[:password]) - tip_exception '用户名或者密码错误' if bind_user.blank? - tip_exception '用户名或者密码错误' unless bind_user.check_password?(params[:password].to_s) - tip_exception '该账号已被绑定,请更换其他账号进行绑定' if bind_user.bind_open_user?(params[:type].to_s) - - OpenUsers::Wechat.create!(user: bind_user, uid: session[:unionid]) - successful_authentication(bind_user) - - render_ok - rescue Exception => e - render_error(e.message) + if params[:type] == "qq" + begin + user = CreateBindUserService.call(current_user, create_params) + successful_authentication(user) if user.id != current_user.id + + render_ok + rescue ApplicationService::Error => ex + render_error(ex.message) + end + else + begin + tip_exception '系统错误' if session[:unionid].blank? + + bind_user = User.try_to_login(params[:username], params[:password]) + tip_exception '用户名或者密码错误' if bind_user.blank? + tip_exception '用户名或者密码错误' unless bind_user.check_password?(params[:password].to_s) + tip_exception '该账号已被绑定,请更换其他账号进行绑定' if bind_user.bind_open_user?(params[:type].to_s) + + OpenUsers::Wechat.create!(user: bind_user, uid: session[:unionid]) + successful_authentication(bind_user) + + render_ok + rescue Exception => e + render_error(e.message) + end + end end def new_user