From 00d6de449928edbaab9249e7f69d78ce5b5f9a86 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Sat, 12 Oct 2019 15:59:33 +0800 Subject: [PATCH] modify auth --- app/services/oauth/create_or_find_qq_account_service.rb | 4 ++-- app/services/oauth/create_or_find_wechat_account_service.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/services/oauth/create_or_find_qq_account_service.rb b/app/services/oauth/create_or_find_qq_account_service.rb index 958b04810..3b3c71367 100644 --- a/app/services/oauth/create_or_find_qq_account_service.rb +++ b/app/services/oauth/create_or_find_qq_account_service.rb @@ -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 # 新用户 diff --git a/app/services/oauth/create_or_find_wechat_account_service.rb b/app/services/oauth/create_or_find_wechat_account_service.rb index 4b3dd4f75..717f4bbd4 100644 --- a/app/services/oauth/create_or_find_wechat_account_service.rb +++ b/app/services/oauth/create_or_find_wechat_account_service.rb @@ -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 # 新用户