增加微信登录开启关闭配置

dependabot/npm_and_yarn/fir_admin/tmpl-1.0.5
youngS 3 years ago
parent ed05083bbe
commit 3c80635d5f
  1. 5
      fir_client/src/components/FirLogin.vue
  2. 4
      fir_client/src/components/user/FirUserProfileInfo.vue
  3. 8
      fir_ser/api/views/login.py
  4. 27
      fir_ser/api/views/thirdlogin.py
  5. 4
      fir_ser/config.py

@ -72,11 +72,12 @@
<el-link :underline="false" @click="$router.push({name: 'FirResetPwd'})" plain>忘记密码</el-link>
</el-form-item>
<div class="other-way">
<div class="other-way" v-if="allow_ways.third && JSON.stringify(allow_ways.third).indexOf('true')!==-1">
<hr>
<span class="info">或使用以下账户登录</span>
<el-popover
v-if="allow_ways.third && allow_ways.third.wxp"
placement="top"
trigger="manual"
title="微信扫码关注公众号登录"
@ -115,7 +116,7 @@
},
cptch: {"cptch_image": '', "cptch_key": '', "length": 8},
activeName: 'username',
allow_ways: {},
allow_ways: {'third':{}},
rutitle: '',
rctitle: '',
register_enable: false,

@ -247,10 +247,10 @@
</el-row>
</el-form-item>
<div class="other-way">
<div class="other-way" v-if="userinfo && userinfo.login_type && userinfo.login_type.third && JSON.stringify(userinfo.login_type.third).indexOf('true')!==-1">
<hr>
<span class="info">绑定第三方账户</span>
<el-row :gutter="20">
<el-row :gutter="20" v-if="userinfo.login_type.third && userinfo.login_type.third.wxp">
<el-col :span="6" :offset="6">
<el-popover
placement="top"

@ -739,13 +739,17 @@ class WeChatLoginView(APIView):
def get(self, request):
ret = BaseResponse()
code, qr_info = make_wx_login_qrcode()
return wx_qr_code_response(ret, code, qr_info)
if get_login_type().get('third', '').get('wxp'):
code, qr_info = make_wx_login_qrcode()
return wx_qr_code_response(ret, code, qr_info)
return Response(ret.dict)
class WeChatLoginCheckView(APIView):
def post(self, request):
ret = BaseResponse()
if not get_login_type().get('third', '').get('wxp'):
return Response(ret.dict)
ticket = request.data.get("ticket")
if ticket:
wx_ticket_data = get_wx_ticket_login_info_cache(ticket)

@ -17,6 +17,7 @@ from api.utils.mp.wechat import check_signature, WxMsgCrypt, get_userinfo_from_o
from api.utils.response import BaseResponse
from api.utils.serializer import ThirdWxSerializer
from api.utils.storage.caches import set_wx_ticket_login_info_cache
from api.views.login import get_login_type
logger = logging.getLogger(__name__)
@ -155,23 +156,25 @@ class ThirdWxAccount(APIView):
def get(self, request):
res = BaseResponse()
# wx_open_id = request.query_params.get("openid", None)
wx_obj_lists = ThirdWeChatUserInfo.objects.filter(user_id=request.user)
# if wx_open_id:
# wx_obj_lists = wx_obj_lists.filter(openid=wx_open_id)
page_obj = PageNumber()
info_serializer = page_obj.paginate_queryset(queryset=wx_obj_lists.order_by("-subscribe_time"),
request=request,
view=self)
wx_user_info = ThirdWxSerializer(info_serializer, many=True, )
res.data = wx_user_info.data
res.count = wx_obj_lists.count()
if get_login_type().get('third', '').get('wxp'):
# wx_open_id = request.query_params.get("openid", None)
wx_obj_lists = ThirdWeChatUserInfo.objects.filter(user_id=request.user)
# if wx_open_id:
# wx_obj_lists = wx_obj_lists.filter(openid=wx_open_id)
page_obj = PageNumber()
info_serializer = page_obj.paginate_queryset(queryset=wx_obj_lists.order_by("-subscribe_time"),
request=request,
view=self)
wx_user_info = ThirdWxSerializer(info_serializer, many=True, )
res.data = wx_user_info.data
res.count = wx_obj_lists.count()
return Response(res.dict)
def delete(self, request):
openid = request.query_params.get("openid")
user_id = request.query_params.get("user_id")
if openid and user_id:
if get_login_type().get('third', '').get('wxp') and openid and user_id:
ThirdWeChatUserInfo.objects.filter(user_id_id=user_id, openid=openid).delete()
return self.get(request)

@ -64,6 +64,7 @@ class CACHECONF(object):
password = ''
# 微信公众号登录配置
class THIRDLOGINCONF(object):
wx_official = {
'name': 'wx_official',
@ -107,6 +108,9 @@ class AUTHCONF(object):
'sms': True, # 短信登录
'email': True, # 邮件登录
'up': False, # 密码登录
'third': {
'wxp': False # 微信公众号登录,需要在 THIRDLOGINCONF 配置好微信公众号登录
},
}
}

Loading…
Cancel
Save