Compare commits

...
4 Commits
Author SHA1 Message Date
Akizon d31d12e59f Merge commit from fork
fix: WS跨域检查
2025-08-09 14:56:45 +08:00
Akizon77 3715f2b3f9 fix: WS跨域检查 2025-08-09 06:52:39 +00:00
github-actions[bot] cc3d54bff4 Merge pull request #180 from komari-monitor/dev
fix: 修复2FA验证逻辑中的错误处理
2025-08-09 06:40:56 +00:00
Akizon77 ef376a88b8 fix: 修复2FA验证逻辑中的错误处理 2025-08-09 06:39:48 +00:00
2 changed files with 12 additions and 2 deletions

No files matched your search

+1 -1
View File
@@ -52,7 +52,7 @@ func Login(c *gin.Context) {
RespondError(c, http.StatusUnauthorized, "2FA code is required")
return
}
if ok, err := accounts.Verify2Fa(uuid, data.TwoFa); err != nil && ok {
if ok, err := accounts.Verify2Fa(uuid, data.TwoFa); err != nil || !ok {
RespondError(c, http.StatusUnauthorized, "Invalid 2FA code")
return
}
+11 -1
View File
@@ -3,6 +3,7 @@ package api
import (
"log"
"net/http"
"net/url"
"time"
"github.com/gin-gonic/gin"
@@ -31,7 +32,16 @@ func RequestTerminal(c *gin.Context) {
}
upgrader := websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
origin := r.Header.Get("Origin")
if origin == "" {
return false
}
host := r.Host
originUrl, err := url.Parse(origin)
if err != nil {
return false
}
return originUrl.Host == host
},
}
conn, err := upgrader.Upgrade(c.Writer, c.Request, nil)