Skip to content

Commit 2ab7ffd

Browse files
committed
fix: modifying password without verifying
1 parent b673edf commit 2ab7ffd

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/pages/app/components/Option/categories/Limit/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const TestButton: FunctionalComponent<{ onClick: NoArgCallback }> = props => (
9797

9898
const _default = defineComponent((_, ctx) => {
9999
const { option } = useOption<tt4b.option.LimitOption>({ defaultValue: DEFAULT_LIMIT, copy })
100-
const { verified, verify } = useVerify(option)
100+
const { verified, verify } = useVerify(option, true)
101101
const { modifyPsw } = usePswEdit({ reset: () => option.limitPassword })
102102
const { setup2fa } = use2faSetup()
103103

src/pages/app/components/Option/categories/Limit/useVerify.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import { listLimits } from "@api/sw/limit"
22
import { judgeVerificationRequired, processVerification } from "@app/util/limit/index"
33
import { ref } from "vue"
44

5-
export const useVerify = (option: tt4b.option.LimitOption) => {
5+
/**
6+
* @param pswRequired must verify password even not triggered yet
7+
*/
8+
export const useVerify = (option: tt4b.option.LimitOption, pswRequired?: boolean) => {
69
const verified = ref(false)
710

811
const verify = async (): Promise<void> => {
@@ -11,7 +14,9 @@ export const useVerify = (option: tt4b.option.LimitOption) => {
1114
const delayDuration = option.limitDelayDuration
1215
const triggerResults = await Promise.all(items.map(item => judgeVerificationRequired(item, delayDuration)))
1316
const anyTrigger = triggerResults.some(t => t)
14-
if (anyTrigger) await processVerification(option)
17+
// Need to verify password at the first time
18+
const verifyPsw = pswRequired && option.limitLevel === 'password'
19+
if (anyTrigger || verifyPsw) await processVerification(option)
1520
verified.value = true
1621
}
1722

0 commit comments

Comments
 (0)