MCPcopy Create free account
hub / github.com/QuantumNous/new-api / requireSecureVerificationMethod

Function requireSecureVerificationMethod

controller/passkey.go:569–586  ·  view source on GitHub ↗
(c *gin.Context, method string)

Source from the content-addressed store, hash-verified

567}
568
569func requireSecureVerificationMethod(c *gin.Context, method string) bool {
570 session := sessions.Default(c)
571 verifiedAt, ok := session.Get(SecureVerificationSessionKey).(int64)
572 if !ok || time.Now().Unix()-verifiedAt >= SecureVerificationTimeout {
573 session.Delete(SecureVerificationSessionKey)
574 session.Delete(secureVerificationMethodSessionKey)
575 _ = session.Save()
576 common.ApiErrorMsg(c, "请先完成安全验证")
577 return false
578 }
579
580 if verifiedMethod, ok := session.Get(secureVerificationMethodSessionKey).(string); !ok || verifiedMethod != method {
581 common.ApiErrorMsg(c, "请先完成对应的安全验证")
582 return false
583 }
584
585 return true
586}

Calls 4

ApiErrorMsgFunction · 0.92
SaveMethod · 0.80
GetMethod · 0.45
DeleteMethod · 0.45

Tested by

no test coverage detected