Skip to content

Commit 2cce784

Browse files
committed
fix: key user does not exist #483
1 parent b0d64e4 commit 2cce784

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

api/user/otp.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/0xJacky/Nginx-UI/api"
1010
"github.com/0xJacky/Nginx-UI/internal/crypto"
1111
"github.com/0xJacky/Nginx-UI/internal/user"
12+
"github.com/0xJacky/Nginx-UI/model"
1213
"github.com/0xJacky/Nginx-UI/query"
1314
"github.com/0xJacky/Nginx-UI/settings"
1415
"github.com/gin-gonic/gin"
@@ -165,14 +166,19 @@ func ResetOTP(c *gin.Context) {
165166
}
166167

167168
func OTPStatus(c *gin.Context) {
169+
status := false
170+
u, ok := c.Get("user")
171+
if ok {
172+
status = u.(*model.Auth).EnabledOTP()
173+
}
168174
c.JSON(http.StatusOK, gin.H{
169-
"status": len(api.CurrentUser(c).OTPSecret) > 0,
175+
"status": status,
170176
})
171177
}
172178

173179
func SecureSessionStatus(c *gin.Context) {
174-
cUser := api.CurrentUser(c)
175-
if !cUser.EnabledOTP() {
180+
u, ok := c.Get("user")
181+
if !ok || !u.(*model.Auth).EnabledOTP() {
176182
c.JSON(http.StatusOK, gin.H{
177183
"status": false,
178184
})
@@ -189,12 +195,13 @@ func SecureSessionStatus(c *gin.Context) {
189195
return
190196
}
191197

192-
if user.VerifySecureSessionID(ssid, cUser.ID) {
198+
if user.VerifySecureSessionID(ssid, u.(*model.Auth).ID) {
193199
c.JSON(http.StatusOK, gin.H{
194200
"status": true,
195201
})
196202
return
197203
}
204+
198205
c.JSON(http.StatusOK, gin.H{
199206
"status": false,
200207
})

app/components.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* eslint-disable */
2-
/* prettier-ignore */
32
// @ts-nocheck
43
// Generated by unplugin-vue-components
54
// Read more: https://github.com/vuejs/core/pull/3399
65
export {}
76

7+
/* prettier-ignore */
88
declare module 'vue' {
99
export interface GlobalComponents {
1010
AAlert: typeof import('ant-design-vue/es')['Alert']

0 commit comments

Comments
 (0)