云服务器安装1Panel面板,开启2FA认证后验证报出服务内部错误: code is not valid

类似的情况出现过好几次,并且不只是在1Panel的2FA认证上。

原因:2FA对时间极其敏感,服务器时间与本地不一致就会出现该问题

解决方案1:

1Panel面板打开工具箱,将时区调整为Asia/Shanghai即可

解决方案2:

一般调完时区就解决了,但某次使用RN的服务器调完还是出现该问题,最终发现是服务器的时间同步服务没有拉起,对此检查及解决步骤如下:

1.检查时区状态
timedatectl
2.若未开启同步则需要安装NTP
# CentOS/RHEL
sudo yum install chrony
# Ubuntu/Debian
sudo apt-get install chrony
3.允许并启用chronyd服务
sudo systemctl start chronyd
sudo systemctl enable chronyd
4.开启同步并查看同步状态
# 强制同步
sudo chronyc -a makestep
# 查看同步状态
chronyc tracking
5.若出错则检查配置文件
vi /etc/chrony.conf
6.将默认服务器替换为中国服务器
# Alibaba Cloud NTP Server
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
server ntp4.aliyun.com iburst
# Asia NTP Pool
server 0.asia.pool.ntp.org iburst
server 1.asia.pool.ntp.org iburst
server 2.asia.pool.ntp.org iburst
7.保存后重启chronyd服务
sudo systemctl restart chronyd
8.检查服务状态应该已经正常
sudo systemctl status chronyd

<template> <el-card> <div class="main-box"> <el-form ref="formRef" :model="preApprovalList" require-asterisk-position="right"> <el-table ref="tableRef" :data="preApprovalList" style="z-index: 900" :span-method="objectSpanMethod" @selection-change="handleSelectionChange"> <el-table-column label="Panel" prop="panel" width="160"></el-table-column> <el-table-column label="Select" prop="select" type="selection" width="80" :selectable="isDisabled"></el-table-column> <el-table-column prop="preApprovalName" label="Item" width="300"></el-table-column> <el-table-column label="Pre-approval Threshold"> <template #default="scope"> <el-row style="display: flex;flex-wrap: unset;"> <el-form-item v-if="scope.row.preApprovalThreshold?.includes('1')" :prop="`preApprovalList.${scope.$index}.exceedLimit`" :rules="scope.row.isChecked === '1'?rules.exceedLimit:''" label="Exceed Limit"> <el-input-number :disabled="scope.row.isChecked === '0'" v-model="scope.row.exceedLimit" :min="0" :max="9999999.99" controls-position="right" style="width: 120px" :step="0.1" :precision="2"/> </el-form-item> <el-form-item v-if="scope.row.preApprovalThreshold?.includes('2')" :prop="`preApprovalList.${scope.$index}.exceedDay`" :rules="scope.row.isChecked === '1'?rules.exceedDay:''" label="Exceed Days"> <el-input-number :disabled="scope.row.isChecked === '0'" v-model="scope.row.exceedDay" :min="0" :max="9999999.99" controls-position="right" style="width: 120px" :step="0.1" :precision="2"/> </el-form-item> <el-form-item v-if="scope.row.preApprovalThreshold?.includes('3')" :prop="`preApprovalList.${scope.$index}.exceedVisit`" :rules="scope.row.isChecked === '1'?rules.exceedVisit:''" label="Exceed Visit"> <el-input-number :disabled="scope.row.isChecked === '0'" v-model="scope.row.exceedVisit" :min="0" :max="9999999.99" controls-position="right" style="width: 120px" :step="0.1" :precision="2"/> </el-form-item> </el-row> </template> </el-table-column> </el-table> </el-form> </div> </el-card> </template> <script setup> import { ref, watch, onMounted, nextTick } from "vue"; import { storeToRefs } from 'pinia' import { useCodeStore } from '@/store/base' import utils, { debounce } from "@/tools/utils"; const codeStore = useCodeStore() const { codeList } = storeToRefs(codeStore) const props = defineProps({ groupSchemeBenefitInfosList: { type: Object, default: {} }, groupSchemeShareBenefitFactorsList: { type: Object, default: {} }, form: { type: Object, default: {} }, disabled: { type: Boolean, default: false } }) const rules = ref({ exceedLimit: [ { required: true, message: 'Please input exceedLimit', trigger: 'blur' } ], exceedDay: [ { required: true, message: 'Please input exceedDay', trigger: 'blur' } ], exceedVisit: [ { required: true, message: 'Please input exceedVisit', trigger: 'blur' } ] }) const tableRef = ref(); const preApprovalList = ref([]); const selectedData = ref([]); // 新增用于存储选中数据的变量 // 处理表格选中变化 const handleSelectionChange = (selection) => { console.log('selection', selection); // 遍历 preApprovalList 中的每一项 preApprovalList.value.forEach(row => { // 检查当前行是否在 selection 数组中 const isSelected = selection.some(selectedRow => selectedRow.preApprovalName === row.preApprovalName ); // 如果在 selection 数组中则设为 '1',否则设为 '0' row.isChecked = isSelected ? '1' : '0'; }); selectedData.value = selection; }; // 根据 preApprovalName 获取对应的选项列表 const getOptionList = (preApprovalName) => { const specialNames = ['Clinical Surgery', 'Confinement', 'Cancer Treatment']; if (specialNames.includes(preApprovalName)) { return codeList.value['E00098'] ?? []; } else { return codeList.value['E00104'] ?? []; // 使用 E00104 作为默认值 } }; const isRowSelected = (row) => { // 检查当前行是否在选中列表中 return selectedData.value.some(selectedRow => selectedRow.preApprovalName === row.preApprovalName); }; watch( () => props.form, debounce(async (newVal3) => { if (utils.isNotEmpty(newVal3?.preApprovalList)) { preApprovalList.value = newVal3.preApprovalList.map(item => ({ ...item, })); // 等待DOM更新后设置选中状态 await nextTick(); // 设置默认选中项 const defaultSelectedRows = preApprovalList.value.filter(item => item.isChecked === '1'); if (defaultSelectedRows.length > 0 && tableRef.value) { defaultSelectedRows.forEach(row => { tableRef.value.toggleRowSelection(row, true); }); } } }, 300), { immediate: true } ); const objectSpanMethod = ({ row, column, rowIndex, columnIndex }) => { if (columnIndex === 0) { if (rowIndex > 0) { if (preApprovalList.value[rowIndex].panel === preApprovalList.value[rowIndex - 1].panel) { return { rowspan: 0, colspan: 0 }; } else { let rowspan = 1; for (let i = rowIndex + 1; i < preApprovalList.value.length; i++) { if (preApprovalList.value[i].panel === preApprovalList.value[rowIndex].panel) { rowspan++; } else { break; } } return { rowspan: rowspan, colspan: 1 }; } } else { let rowspan = 1; for (let i = rowIndex + 1; i < preApprovalList.value.length; i++) { if (preApprovalList.value[i].panel === preApprovalList.value[rowIndex].panel) { rowspan++; } else { break; } } return { rowspan: rowspan, colspan: 1 }; } } }; const isDisabled = (row,index) => { return !props.disabled; }; const formRef = ref(); function validateRefs() { return new Promise((resolve, reject) => { formRef.value.validate((valid,invalidFields) => { if (valid) { resolve(true); } else { // 只提示第一个错误字段的错误信息 // for (const field in invalidFields) { // const errors = invalidFields[field]; // if (errors.length > 0) { // const firstError = errors[0]; // 取第一个错误 // utils.message('Pre-Approval: ' + firstError.message, 'error'); // break; // 停止继续遍历 // } // } utils.message('Pre-Approval: Please input Pre-approval Threshold', 'error'); reject(false); } }); }); } // 暴露 preApprovalList 和 selectedData defineExpose({ preApprovalList, validateRefs }) onMounted(() => { }); </script> <style scoped lang="less"> .pagination-box { display: flex; justify-content: space-between; padding: 0 28px; align-items: center; height: 64px; p { color: rgba(0, 0, 0, 0.6); } } :deep(.el-form-item) { margin-bottom: 0 !important; } :deep(.el-form-item__label) { width: 120px !important; margin-left: 20px; } </style>
11-14
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值