This commit is contained in:
parent
64ad182a84
commit
b9280caf36
|
@ -8,15 +8,13 @@ module Mobile
|
|||
desc "绑定微信用户"
|
||||
params do
|
||||
requires :login, type: String, desc: 'username'
|
||||
requires :mail, type: String, desc: 'mail'
|
||||
requires :password, type: String, desc: 'password'
|
||||
requires :openid, type: String, desc: 'wechat openid'
|
||||
end
|
||||
post 'wxbind' do
|
||||
code = params[:code] || session[:wechat_code]
|
||||
openid = get_openid_from_code(code)
|
||||
|
||||
openid = params[:openid]
|
||||
raise "无法获取到openid,请在微信中打开本页面" unless openid
|
||||
raise "此微信号已绑定用户, 不能重复绑定" if user_binded?(openid)
|
||||
raise "此微信号已绑定用户, 不能重复绑定" if UserWechat.where(openid: openid).first
|
||||
|
||||
user, last_login_on = User.try_to_login(params[:username], params[:password])
|
||||
raise "用户名或密码错误,请重新输入" unless user
|
||||
|
|
Loading…
Reference in New Issue