This commit is contained in:
jxxghp
2024-04-02 16:36:27 +08:00
parent ce0dda0455
commit 8b4b79fa10
3 changed files with 15 additions and 15 deletions
+1 -1
View File
@@ -851,7 +851,7 @@ export interface User {
// 头像 // 头像
avatar: string avatar: string
// 是否开启二次验证 // 是否开启双重验证
is_otp: boolean is_otp: boolean
} }
+5 -5
View File
@@ -31,7 +31,7 @@ const backgroundImageUrl = ref('')
// 背景图片加载状态 // 背景图片加载状态
const isImageLoaded = ref(false) const isImageLoaded = ref(false)
// 是否开启二次验证 // 是否开启双重验证
const isOTP = ref(false) const isOTP = ref(false)
// 用户名称输入框 // 用户名称输入框
@@ -49,7 +49,7 @@ async function fetchBackgroundImage() {
}) })
} }
// 查询是否开启二次验证 // 查询是否开启双重验证
async function fetchOTP() { async function fetchOTP() {
const userid = usernameInput.value?.value const userid = usernameInput.value?.value
if (!userid) { if (!userid) {
@@ -111,13 +111,13 @@ function login() {
if (!error.response) if (!error.response)
errorMessage.value = '登录失败,请检查网络连接' errorMessage.value = '登录失败,请检查网络连接'
else if (error.response.status === 401) else if (error.response.status === 401)
errorMessage.value = '登录失败,请检查用户名、密码或二次验证是否正确' errorMessage.value = '登录失败,请检查用户名、密码或双重验证是否正确'
else if (error.response.status === 403) else if (error.response.status === 403)
errorMessage.value = '登录失败,您没有权限访问' errorMessage.value = '登录失败,您没有权限访问'
else if (error.response.status === 500) else if (error.response.status === 500)
errorMessage.value = '登录失败,服务器错误' errorMessage.value = '登录失败,服务器错误'
else else
errorMessage.value = `登录失败 ${error.response.status},请检查用户名、密码或二次验证码是否正确` errorMessage.value = `登录失败 ${error.response.status},请检查用户名、密码或双重验证码是否正确`
}) })
} }
@@ -199,7 +199,7 @@ onMounted(() => {
<VTextField <VTextField
v-if="isOTP" v-if="isOTP"
v-model="form.otp_password" v-model="form.otp_password"
label="二次验证码" label="双重验证码"
type="input" type="input"
/> />
<!-- remember me checkbox --> <!-- remember me checkbox -->
+9 -9
View File
@@ -21,7 +21,7 @@ const refInputEl = ref<HTMLElement>()
// 新增用户窗口 // 新增用户窗口
const addUserDialog = ref(false) const addUserDialog = ref(false)
// 开启二次验证窗口 // 开启双重验证窗口
const otpDialog = ref(false) const otpDialog = ref(false)
// otp uri // otp uri
@@ -30,7 +30,7 @@ const otpUri = ref('')
// otp secret // otp secret
const secret = ref('') const secret = ref('')
// 确认二次验证密码 // 确认双重验证密码
const otpPassword = ref('') const otpPassword = ref('')
// 新增用户表单 // 新增用户表单
@@ -204,13 +204,13 @@ async function getOtpUri() {
} }
} }
// 关闭当前用户的二次验证 // 关闭当前用户的双重验证
async function disableOtp() { async function disableOtp() {
try { try {
const result: { [key: string]: any } = await api.post('user/otp/disable') const result: { [key: string]: any } = await api.post('user/otp/disable')
if (result.success) { if (result.success) {
accountInfo.value.is_otp = false accountInfo.value.is_otp = false
$toast.success('关闭登录二次验证成功!') $toast.success('关闭登录双重验证成功!')
} }
else { else {
$toast.error(`关闭otp失败:${result.message}`) $toast.error(`关闭otp失败:${result.message}`)
@@ -231,7 +231,7 @@ async function judgeOtpPassword() {
const result: { [key: string]: any } = await api.post('user/otp/judge', { uri: otpUri.value, otpPassword: otpPassword.value }) const result: { [key: string]: any } = await api.post('user/otp/judge', { uri: otpUri.value, otpPassword: otpPassword.value })
if (result.success) { if (result.success) {
$toast.success('开启登录二次验证成功!') $toast.success('开启登录双重验证成功!')
otpDialog.value = false otpDialog.value = false
accountInfo.value.is_otp = true accountInfo.value.is_otp = true
} }
@@ -306,7 +306,7 @@ onMounted(() => {
<VIcon <VIcon
icon="mdi-account-key" icon="mdi-account-key"
/> />
<span class="d-none d-sm-block ms-2">{{ accountInfo.is_otp ? "关闭验证" : "二次验证" }}</span> <span class="d-none d-sm-block ms-2">{{ accountInfo.is_otp ? "关闭验证" : "双重验证" }}</span>
</VBtn> </VBtn>
</div> </div>
@@ -555,19 +555,19 @@ onMounted(() => {
</VCard> </VCard>
</VDialog> </VDialog>
<!-- 二次验证弹窗 --> <!-- 双重验证弹窗 -->
<VDialog <VDialog
v-model="otpDialog" v-model="otpDialog"
max-width="45rem" max-width="45rem"
persistent persistent
z-index="1010" z-index="1010"
> >
<!-- 开启二次验证弹窗内容 --> <!-- 开启双重验证弹窗内容 -->
<VCard> <VCard>
<DialogCloseBtn @click="otpDialog = false" /> <DialogCloseBtn @click="otpDialog = false" />
<VCardText> <VCardText>
<h4 class="text-h4 text-center mb-6 mt-5"> <h4 class="text-h4 text-center mb-6 mt-5">
登录二次验证 登录双重验证
</h4><h5 class="text-h5 font-weight-medium mb-2"> </h4><h5 class="text-h5 font-weight-medium mb-2">
身份验证器 身份验证器
</h5> </h5>