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

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. 4
      fir_ser/api/views/login.py
  4. 5
      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-link :underline="false" @click="$router.push({name: 'FirResetPwd'})" plain>忘记密码</el-link>
</el-form-item> </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> <hr>
<span class="info">或使用以下账户登录</span> <span class="info">或使用以下账户登录</span>
<el-popover <el-popover
v-if="allow_ways.third && allow_ways.third.wxp"
placement="top" placement="top"
trigger="manual" trigger="manual"
title="微信扫码关注公众号登录" title="微信扫码关注公众号登录"
@ -115,7 +116,7 @@
}, },
cptch: {"cptch_image": '', "cptch_key": '', "length": 8}, cptch: {"cptch_image": '', "cptch_key": '', "length": 8},
activeName: 'username', activeName: 'username',
allow_ways: {}, allow_ways: {'third':{}},
rutitle: '', rutitle: '',
rctitle: '', rctitle: '',
register_enable: false, register_enable: false,

@ -247,10 +247,10 @@
</el-row> </el-row>
</el-form-item> </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> <hr>
<span class="info">绑定第三方账户</span> <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-col :span="6" :offset="6">
<el-popover <el-popover
placement="top" placement="top"

@ -739,13 +739,17 @@ class WeChatLoginView(APIView):
def get(self, request): def get(self, request):
ret = BaseResponse() ret = BaseResponse()
if get_login_type().get('third', '').get('wxp'):
code, qr_info = make_wx_login_qrcode() code, qr_info = make_wx_login_qrcode()
return wx_qr_code_response(ret, code, qr_info) return wx_qr_code_response(ret, code, qr_info)
return Response(ret.dict)
class WeChatLoginCheckView(APIView): class WeChatLoginCheckView(APIView):
def post(self, request): def post(self, request):
ret = BaseResponse() ret = BaseResponse()
if not get_login_type().get('third', '').get('wxp'):
return Response(ret.dict)
ticket = request.data.get("ticket") ticket = request.data.get("ticket")
if ticket: if ticket:
wx_ticket_data = get_wx_ticket_login_info_cache(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.response import BaseResponse
from api.utils.serializer import ThirdWxSerializer from api.utils.serializer import ThirdWxSerializer
from api.utils.storage.caches import set_wx_ticket_login_info_cache from api.utils.storage.caches import set_wx_ticket_login_info_cache
from api.views.login import get_login_type
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -155,6 +156,8 @@ class ThirdWxAccount(APIView):
def get(self, request): def get(self, request):
res = BaseResponse() res = BaseResponse()
if get_login_type().get('third', '').get('wxp'):
# wx_open_id = request.query_params.get("openid", None) # wx_open_id = request.query_params.get("openid", None)
wx_obj_lists = ThirdWeChatUserInfo.objects.filter(user_id=request.user) wx_obj_lists = ThirdWeChatUserInfo.objects.filter(user_id=request.user)
# if wx_open_id: # if wx_open_id:
@ -172,6 +175,6 @@ class ThirdWxAccount(APIView):
def delete(self, request): def delete(self, request):
openid = request.query_params.get("openid") openid = request.query_params.get("openid")
user_id = request.query_params.get("user_id") 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() ThirdWeChatUserInfo.objects.filter(user_id_id=user_id, openid=openid).delete()
return self.get(request) return self.get(request)

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

Loading…
Cancel
Save