1 parent
435595f061
commit
fe3e330577
5 files changed
+17
-2
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
export const RECOVERY_CODE_DISPLAY_MS = 60 * 1000
|
||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
import { useGlobalStatusStore } from '@/stores/useGlobalStatusStore'
|
import { useGlobalStatusStore } from '@/stores/useGlobalStatusStore'
|
||||||
import { normalizeCreationOptions, serializeCredential, webAuthnSupported } from '@/utils/webauthn'
|
import { normalizeCreationOptions, serializeCredential, webAuthnSupported } from '@/utils/webauthn'
|
||||||
import { downloadRecoveryCodes } from '@/utils/recoveryCodeDownload'
|
import { downloadRecoveryCodes } from '@/utils/recoveryCodeDownload'
|
||||||
|
import { RECOVERY_CODE_DISPLAY_MS } from '@/utils/recoveryCodeDisplay'
|
||||||
|
|
||||||
export function usePage() {
|
export function usePage() {
|
||||||
const globalStatus = useGlobalStatusStore()
|
const globalStatus = useGlobalStatusStore()
|
||||||
@@ -270,7 +271,7 @@ export function usePage() {
|
|||||||
|
|
||||||
const scheduleRecoveryCodeHide = () => {
|
const scheduleRecoveryCodeHide = () => {
|
||||||
clearTimeout(recoveryCodeHideTimer)
|
clearTimeout(recoveryCodeHideTimer)
|
||||||
recoveryCodeHideTimer = setTimeout(clearRecoveryCodes, 60000)
|
recoveryCodeHideTimer = setTimeout(clearRecoveryCodes, RECOVERY_CODE_DISPLAY_MS)
|
||||||
}
|
}
|
||||||
|
|
||||||
const revealRecoveryCodes = async () => {
|
const revealRecoveryCodes = async () => {
|
||||||
|
|||||||
+2
-1
@@ -7,6 +7,7 @@ import {
|
|||||||
isRecentAuthenticationCancelled,
|
isRecentAuthenticationCancelled,
|
||||||
requestWithRecentAuthentication,
|
requestWithRecentAuthentication,
|
||||||
} from '@/utils/recentAuthentication'
|
} from '@/utils/recentAuthentication'
|
||||||
|
import { RECOVERY_CODE_DISPLAY_MS } from '@/utils/recoveryCodeDisplay'
|
||||||
|
|
||||||
export const recoveryCodeDialogProps = {
|
export const recoveryCodeDialogProps = {
|
||||||
modelValue: {
|
modelValue: {
|
||||||
@@ -52,7 +53,7 @@ export function useRecoveryCodeDialog(props, emit) {
|
|||||||
|
|
||||||
const scheduleHide = () => {
|
const scheduleHide = () => {
|
||||||
clearTimeout(hideTimer)
|
clearTimeout(hideTimer)
|
||||||
hideTimer = setTimeout(clearCodes, 60000)
|
hideTimer = setTimeout(clearCodes, RECOVERY_CODE_DISPLAY_MS)
|
||||||
}
|
}
|
||||||
|
|
||||||
const isCurrentView = (version, userID) => (
|
const isCurrentView = (version, userID) => (
|
||||||
|
|||||||
@@ -1,6 +1,17 @@
|
|||||||
import assert from 'node:assert/strict'
|
import assert from 'node:assert/strict'
|
||||||
import test from 'node:test'
|
import test from 'node:test'
|
||||||
|
import { readFileSync } from 'node:fs'
|
||||||
import { downloadRecoveryCodes } from '../../frontend/src/utils/recoveryCodeDownload.js'
|
import { downloadRecoveryCodes } from '../../frontend/src/utils/recoveryCodeDownload.js'
|
||||||
|
import { RECOVERY_CODE_DISPLAY_MS } from '../../frontend/src/utils/recoveryCodeDisplay.js'
|
||||||
|
|
||||||
|
const securitySettingsSource = readFileSync(new URL('../../frontend/src/views/components/SecuritySettings/SecuritySettings.js', import.meta.url), 'utf8')
|
||||||
|
const securitySettingsTemplate = readFileSync(new URL('../../frontend/src/views/components/SecuritySettings/SecuritySettings.vue', import.meta.url), 'utf8')
|
||||||
|
|
||||||
|
test('security codes use a shared 60-second display timeout', () => {
|
||||||
|
assert.equal(RECOVERY_CODE_DISPLAY_MS, 60000)
|
||||||
|
assert.match(securitySettingsSource, /setTimeout\(clearRecoveryCodes, RECOVERY_CODE_DISPLAY_MS\)/)
|
||||||
|
assert.match(securitySettingsTemplate, /one-time-tip/)
|
||||||
|
})
|
||||||
|
|
||||||
function createDocumentFixture() {
|
function createDocumentFixture() {
|
||||||
const anchors = []
|
const anchors = []
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ test('用户安全信息使用独立弹窗并调用固定管理接口', () => {
|
|||||||
const recoverySource = read('RecoveryCodeDialog/RecoveryCodeDialog.js')
|
const recoverySource = read('RecoveryCodeDialog/RecoveryCodeDialog.js')
|
||||||
assert.match(recoverySource, /\/api\/v1\/user\/security\/recovery-codes\/generate/)
|
assert.match(recoverySource, /\/api\/v1\/user\/security\/recovery-codes\/generate/)
|
||||||
assert.match(recoverySource, /shown_once|codes/)
|
assert.match(recoverySource, /shown_once|codes/)
|
||||||
|
assert.match(recoverySource, /setTimeout\(clearCodes, RECOVERY_CODE_DISPLAY_MS\)/)
|
||||||
const externalSource = read('UserExternalEmailDialog/UserExternalEmailDialog.js')
|
const externalSource = read('UserExternalEmailDialog/UserExternalEmailDialog.js')
|
||||||
assert.match(externalSource, /\/api\/v1\/user\/security\/external-email\/change/)
|
assert.match(externalSource, /\/api\/v1\/user\/security\/external-email\/change/)
|
||||||
assert.match(externalSource, /\/api\/v1\/user\/security\/external-email\/verify/)
|
assert.match(externalSource, /\/api\/v1\/user\/security\/external-email\/verify/)
|
||||||
|
|||||||
Reference in new issue
Block a user