modify auth

competitions
p31729568 5 years ago
parent 5c66769b54
commit 00d6de4499

@ -8,11 +8,11 @@ class Oauth::CreateOrFindQqAccountService < ApplicationService
end
def call
new_user = false
# 存在该用户
open_user = OpenUsers::QQ.find_by(uid: params['uid'])
return open_user.user if open_user.present?
return [open_user.user, new_user] if open_user.present?
new_user = false
if user.blank? || !user.logged?
new_user = true
# 新用户

@ -11,15 +11,15 @@ class Oauth::CreateOrFindWechatAccountService < ApplicationService
def call
code = params['code'].to_s.strip
raise Error, 'Code不能为空' if code.blank?
new_user = false
result = WechatOauth::Service.access_token(code)
result = WechatOauth::Service.user_info(result['access_token'], result['openid'])
# 存在该用户
open_user = OpenUsers::Wechat.find_by(uid: result['unionid'])
return open_user.user if open_user.present?
return [open_user.user, new_user] if open_user.present?
new_user = false
if user.blank? || !user.logged?
new_user = true
# 新用户

Loading…
Cancel
Save