(c *gin.Context, method string)
| 567 | } |
| 568 | |
| 569 | func 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 | } |
no test coverage detected