Skip to content

Commit b68e8a1

Browse files
committed
enhance: do not require 2fa in 2min
1 parent a5dda59 commit b68e8a1

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

app/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@vue/reactivity": "^3.4.33",
1717
"@vue/shared": "^3.4.33",
1818
"@vueuse/core": "^10.11.0",
19+
"@vueuse/integrations": "^10.11.0",
1920
"@xterm/addon-attach": "^0.11.0",
2021
"@xterm/addon-fit": "^0.10.0",
2122
"@xterm/xterm": "^5.5.0",
@@ -31,6 +32,7 @@
3132
"pinia-plugin-persistedstate": "^3.2.1",
3233
"reconnecting-websocket": "^4.4.0",
3334
"sortablejs": "^1.15.2",
35+
"universal-cookie": "^7",
3436
"vite-plugin-build-id": "^0.2.9",
3537
"vue": "^3.4.33",
3638
"vue-github-button": "github:0xJacky/vue-github-button",

app/pnpm-lock.yaml

Lines changed: 81 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/components/OTP/useOTPModal.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createVNode, render } from 'vue'
22
import { Modal, message } from 'ant-design-vue'
3+
import { useCookies } from '@vueuse/integrations/useCookies'
34
import OTPAuthorization from '@/components/OTP/OTPAuthorization.vue'
45
import otp from '@/api/otp'
56

@@ -24,6 +25,14 @@ const useOTPModal = () => {
2425
}
2526

2627
const open = ({ onOk, onCancel }: OTPModalProps) => {
28+
const cookies = useCookies(['nginx-ui-2fa'])
29+
const ssid = cookies.get('secure_session_id')
30+
if (ssid) {
31+
onOk?.(ssid)
32+
33+
return
34+
}
35+
2736
injectStyles()
2837
let container: HTMLDivElement | null = document.createElement('div')
2938
document.body.appendChild(container)
@@ -36,6 +45,7 @@ const useOTPModal = () => {
3645

3746
const verify = (passcode: string, recovery: string) => {
3847
otp.start_secure_session(passcode, recovery).then(r => {
48+
cookies.set('secure_session_id', r.session_id, { maxAge: 60 * 3 })
3949
onOk?.(r.session_id)
4050
close()
4151
}).catch(async () => {

0 commit comments

Comments
 (0)