功能变化: 初始化优化及登录优化
parent
6e4b2a4b19
commit
54dcfbf0fa
|
@ -321,7 +321,6 @@ SWAGGER_SETTINGS = {
|
|||
# ================================================= #
|
||||
# **************** 验证码配置 ******************* #
|
||||
# ================================================= #
|
||||
CAPTCHA_STATE = locals().get("CAPTCHA_STATE", False)
|
||||
CAPTCHA_IMAGE_SIZE = (160, 60) # 设置 captcha 图片大小
|
||||
CAPTCHA_LENGTH = 4 # 字符个数
|
||||
CAPTCHA_TIMEOUT = 1 # 超时(minutes)
|
||||
|
|
|
@ -81,8 +81,6 @@ urlpatterns = (
|
|||
path("api/init/dictionary/", InitDictionaryViewSet.as_view()),
|
||||
path("api/init/settings/", InitSettingsViewSet.as_view()),
|
||||
path("apiLogin/", ApiLogin.as_view()),
|
||||
re_path(r'api/upgrade_center_backend/', include('dvadmin_upgrade_center.urls')),
|
||||
re_path(r'api/dvadmin_upgrade_center/', include('dvadmin_upgrade_center.urls')),
|
||||
]
|
||||
+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
+ static(settings.STATIC_URL, document_root=settings.STATIC_URL)
|
||||
|
|
|
@ -14,7 +14,7 @@ from rest_framework.views import APIView
|
|||
from rest_framework_simplejwt.serializers import TokenObtainPairSerializer
|
||||
from rest_framework_simplejwt.views import TokenObtainPairView
|
||||
|
||||
from application import settings
|
||||
from django.conf import settings
|
||||
from dvadmin.system.models import Users
|
||||
from dvadmin.utils.json_response import ErrorResponse, DetailResponse
|
||||
from dvadmin.utils.request_util import save_login_log
|
||||
|
@ -34,7 +34,7 @@ class CaptchaView(APIView):
|
|||
)
|
||||
def get(self, request):
|
||||
data = {}
|
||||
if settings.CAPTCHA_STATE:
|
||||
if settings.SYSTEM_CONFIG.get("base.captcha_state"):
|
||||
hashkey = CaptchaStore.generate_key()
|
||||
id = CaptchaStore.objects.filter(hashkey=hashkey).first().id
|
||||
imgage = captcha_image(request, hashkey)
|
||||
|
@ -47,15 +47,6 @@ class CaptchaView(APIView):
|
|||
return DetailResponse(data=data)
|
||||
|
||||
|
||||
class CaptchaStatusView(APIView):
|
||||
|
||||
authentication_classes = []
|
||||
permission_classes = []
|
||||
|
||||
def get(self, request):
|
||||
return DetailResponse(data={"status": settings.CAPTCHA_STATE})
|
||||
|
||||
|
||||
class LoginSerializer(TokenObtainPairSerializer):
|
||||
"""
|
||||
登录的序列化器:
|
||||
|
@ -75,7 +66,7 @@ class LoginSerializer(TokenObtainPairSerializer):
|
|||
|
||||
def validate(self, attrs):
|
||||
captcha = self.initial_data.get("captcha", None)
|
||||
if settings.CAPTCHA_STATE:
|
||||
if settings.SYSTEM_CONFIG.get("base.captcha_state"):
|
||||
if captcha is None:
|
||||
raise CustomValidationError("验证码不能为空")
|
||||
self.image_code = CaptchaStore.objects.filter(
|
||||
|
|
|
@ -40,9 +40,6 @@ class UserCreateSerializer(CustomModelSerializer):
|
|||
)
|
||||
password = serializers.CharField(
|
||||
required=False,
|
||||
default=make_password(
|
||||
hashlib.md5(settings.DEFAULT_PASSWORD.encode(encoding="UTF-8")).hexdigest()
|
||||
),
|
||||
)
|
||||
|
||||
def validate_password(self, value):
|
||||
|
@ -255,7 +252,7 @@ class UserViewSet(CustomModelViewSet):
|
|||
"""恢复默认密码"""
|
||||
instance = Users.objects.filter(id=kwargs.get("pk")).first()
|
||||
if instance:
|
||||
instance.set_password(settings.DEFAULT_PASSWORD)
|
||||
instance.set_password(settings.SYSTEM_CONFIG.get("base.default_password"))
|
||||
instance.save()
|
||||
return DetailResponse(data=None, msg="密码重置成功")
|
||||
else:
|
||||
|
|
|
@ -23,7 +23,7 @@ export default {
|
|||
helpUrl: this.systemConfig('login.help_url'), // 帮助
|
||||
privacyUrl: this.systemConfig('login.privacy_url'), // 隐私
|
||||
clauseUrl: this.systemConfig('login.clause_url'), // 条款
|
||||
captchaState: this.systemConfig('login.captcha_state'), // 验证码
|
||||
captchaState: this.systemConfig('base.captcha_state'), // 验证码
|
||||
processTitle: process.env.VUE_APP_TITLE || 'D2Admin',
|
||||
backgroundImage: 'url(' + this.loginBackground + ')',
|
||||
// 表单
|
||||
|
@ -68,12 +68,6 @@ export default {
|
|||
}
|
||||
},
|
||||
mounted () {
|
||||
document.onkeydown = () => {
|
||||
var key = window.event.keyCode
|
||||
if (key === 13) {
|
||||
this.submit()
|
||||
}
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
},
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
prefix-icon="el-icon-s-promotion"
|
||||
show-password
|
||||
placeholder="密码"
|
||||
@keyup.enter.native="submit"
|
||||
>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
|
|
|
@ -44,7 +44,7 @@ export function DelObj (id) {
|
|||
|
||||
/**
|
||||
* 重置密码
|
||||
* @param id
|
||||
* @param obj
|
||||
* @returns {*}
|
||||
* @constructor
|
||||
*/
|
||||
|
@ -55,11 +55,3 @@ export function ResetPwd (obj) {
|
|||
data: obj
|
||||
})
|
||||
}
|
||||
|
||||
export function ResetPwd2Default (obj) {
|
||||
return request({
|
||||
url: urlPrefix + 'reset_to_default_password/' + obj.id + '/',
|
||||
method: 'put',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ export const crudOptions = (vm) => {
|
|||
rowKey: true // 必须设置,true or false
|
||||
},
|
||||
rowHandle: {
|
||||
width: 270,
|
||||
width: 240,
|
||||
fixed: 'right',
|
||||
view: {
|
||||
thin: true,
|
||||
|
@ -38,7 +38,7 @@ export const crudOptions = (vm) => {
|
|||
custom: [
|
||||
{
|
||||
thin: true,
|
||||
text: '',
|
||||
text: '密码重置',
|
||||
size: 'small',
|
||||
type: 'warning',
|
||||
icon: 'el-icon-refresh-left',
|
||||
|
@ -46,18 +46,6 @@ export const crudOptions = (vm) => {
|
|||
return vm.hasPermissions('ResetPassword')
|
||||
},
|
||||
emit: 'resetPassword'
|
||||
},
|
||||
{
|
||||
show () {
|
||||
return vm.hasPermissions('DefaultPassword')
|
||||
},
|
||||
disabled () {
|
||||
return !vm.hasPermissions('DefaultPassword')
|
||||
},
|
||||
text: '重置密码',
|
||||
type: 'warning',
|
||||
size: 'small',
|
||||
emit: 'defaultPassword'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -128,11 +116,18 @@ export const crudOptions = (vm) => {
|
|||
minWidth: 90,
|
||||
type: 'input',
|
||||
form: {
|
||||
rules: [ // 表单校验规则
|
||||
{
|
||||
required: true,
|
||||
message: '密码必填项'
|
||||
}
|
||||
],
|
||||
component: {
|
||||
span: 12,
|
||||
showPassword: true,
|
||||
placeholder: '不填则默认为:admin123456'
|
||||
placeholder: '请输入密码'
|
||||
},
|
||||
value: vm.systemConfig('base.default_password'),
|
||||
itemProps: {
|
||||
class: { yxtInput: true }
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
v-bind="_crudProps"
|
||||
v-on="_crudListeners"
|
||||
@resetPassword="resetPassword"
|
||||
@defaultPassword="defaultPassword"
|
||||
>
|
||||
<div slot="header">
|
||||
<crud-search
|
||||
|
@ -36,6 +35,7 @@
|
|||
title="密码重置"
|
||||
:visible.sync="dialogFormVisible"
|
||||
:close-on-click-modal="false"
|
||||
width="30%"
|
||||
>
|
||||
<el-form :model="resetPwdForm" ref="resetPwdForm" :rules="passwordRules">
|
||||
<el-form-item label="密码" prop="pwd">
|
||||
|
@ -59,7 +59,7 @@
|
|||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogFormVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="resetPwdSubmit">确 定</el-button>
|
||||
<el-button type="primary" @click="resetPwdSubmit">重 置</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</d2-container>
|
||||
|
@ -132,11 +132,6 @@ export default {
|
|||
delRequest (row) {
|
||||
return api.DelObj(row.id)
|
||||
},
|
||||
defaultPassword (scope) {
|
||||
api.ResetPwd2Default(scope.row).then((res) => {
|
||||
this.$message.success('密码重置成功')
|
||||
})
|
||||
},
|
||||
// 重置密码弹框
|
||||
resetPassword ({ row }) {
|
||||
this.dialogFormVisible = true
|
||||
|
|
Loading…
Reference in New Issue