You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
849 B
23 lines
849 B
class Weapps::SessionsController < Weapps::BaseController
|
|
before_action :require_wechat_login!
|
|
|
|
def create
|
|
return render_error('重复登录') if current_user.present? && current_user.logged?
|
|
|
|
user = User.try_to_login(params[:login], params[:password])
|
|
|
|
return render_error('错误的账号或密码') if user.blank?
|
|
return render_error('违反平台使用规范,账号已被锁定') if user.locked?
|
|
return render_error('错误的账号或密码') unless user.check_password?(params[:password].to_s)
|
|
|
|
if user.wechat_open_user && user.wechat_open_user.uid != session_unionid
|
|
render_error('该账号已被其它微信号绑定')
|
|
return
|
|
end
|
|
|
|
# 绑定微信号
|
|
OpenUsers::Wechat.create!(user: user, uid: session_unionid) if user.wechat_open_user.blank?
|
|
|
|
successful_authentication(user)
|
|
end
|
|
end |