微信web登录跳转优化

dependabot/npm_and_yarn/fir_admin/async-2.6.4
nineven 3 years ago
parent ae9dfae6a3
commit 2390397f1b
  1. 2
      fir_ser/api/views/login_wx.py
  2. 10
      fir_ser/common/core/sysconfig.py
  3. 10
      fir_ser/common/libs/mp/wechat.py

@ -206,7 +206,7 @@ class WeChatWebLoginView(APIView):
if info and isinstance(info, dict):
info.update({'w_type': 'web', 'to_user': wx_user_info.get('openid')})
set_wx_ticket_login_info_cache(state, info)
return redirect(Config.WEB_DOMAIN)
return redirect(Config.WECHAT_WEB_SUCCESS_REDIRECT_URI)
return Response(ret.dict)

@ -64,7 +64,7 @@ class ConfigCacheBase(object):
def get_value_from_db(self, key):
data = SystemConfigSerializer(SystemConfig.objects.filter(enable=True, key=key).first()).data
if re.findall('{{.*%s.*}}' % data['key'], data['value']):
logger.warning(f"get same render key. so get default value")
logger.warning(f"get same render key:{key}. so get default value")
data['key'] = ''
return data
@ -121,6 +121,14 @@ class ConfigCacheBase(object):
def FILE_UPLOAD_DOMAIN(self):
return self.get_value('FILE_UPLOAD_DOMAIN', self.API_DOMAIN)
@property
def WECHAT_WEB_SUCCESS_REDIRECT_URI(self):
return self.get_value('WECHAT_WEB_SUCCESS_REDIRECT_URI', self.WEB_DOMAIN)
@property
def WECHAT_WEB_LOGIN_REDIRECT_DOMAIN(self):
return self.get_value('WECHAT_WEB_LOGIN_REDIRECT_DOMAIN')
class BaseConfCache(ConfigCacheBase):
def __init__(self):

@ -6,6 +6,7 @@
import json
import logging
import urllib
from urllib.parse import quote
from hashlib import sha1
import requests
@ -572,9 +573,12 @@ class WxWebLogin(object):
:return:
"""
# url = 'https://app.hehelucky.cn/api/v1/fir/server/wxweb' # 该url是前端页面,用户微信跳转,后端页面也行
local_storage = LocalStorage(**Config.IOS_PMFILE_DOWNLOAD_DOMAIN)
url = f'{local_storage.get_base_url()}{reverse("mp.web.login")}'
encode_url = urllib.parse.quote(url, safe='/', encoding=None, errors=None)
redirect_domain = Config.WECHAT_WEB_LOGIN_REDIRECT_DOMAIN
if not redirect_domain:
local_storage = LocalStorage(**Config.IOS_PMFILE_DOWNLOAD_DOMAIN)
redirect_domain = local_storage.get_base_url()
url = f'{redirect_domain}{reverse("mp.web.login")}'
encode_url = quote(url, safe='/', encoding=None, errors=None)
code_url = f'https://open.weixin.qq.com/connect/oauth2/authorize?appid={self.app_id}&redirect_uri={encode_url}&response_type=code&scope=snsapi_userinfo&state={state}#wechat_redirect '
return code_url

Loading…
Cancel
Save