完善授权分页与恢复安全校验
Security Checks / security (push) Waiting to run

This commit is contained in:
xuans committed 2026-09-06 07:22:00 +08:00
1 parent d93337852d
commit dbcfc5c461
6 files changed
+36 -16

No files matched your search

+11 -4
View File
@@ -27,11 +27,14 @@ func getList(ctx *context.Context, tagInfo dto.SearchTag, keyword string, pop3Li
totalSQL, totalParams := genSQL(ctx, true, tagInfo, keyword, pop3List, offset, limit)
if _, err := db.Instance.SQL(totalSQL, totalParams...).Get(&total); err != nil {
var countResult struct {
Total int64 `xorm:"total"`
}
if _, err := db.Instance.SQL(totalSQL, totalParams...).Get(&countResult); err != nil {
return nil, 0, fmt.Errorf("query email count: %w", err)
}
return emailList, total, nil
return emailList, countResult.Total, nil
}
func genSQL(ctx *context.Context, count bool, tagInfo dto.SearchTag, keyword string, pop3List bool, offset, limit int) (string, []any) {
@@ -39,7 +42,7 @@ func genSQL(ctx *context.Context, count bool, tagInfo dto.SearchTag, keyword str
sql := "select "
if count {
sql += `count(1) from email e left join user_email ue on e.id=ue.email_id where ue.user_id = ? `
sql += `count(1) AS total from email e left join user_email ue on e.id=ue.email_id where ue.user_id = ? `
} else if pop3List {
sql += `e.id,e.size from email e left join user_email ue on e.id=ue.email_id where ue.user_id = ? `
} else {
@@ -94,10 +97,14 @@ func genSQL(ctx *context.Context, count bool, tagInfo dto.SearchTag, keyword str
sqlParams = append(sqlParams, "%"+keyword+"%", "%"+keyword+"%")
}
if limit == 0 {
if !count && limit == 0 {
limit = 10
}
if count {
return sql, sqlParams
}
sql += " order by e.id desc"
if limit < 10000 {
+7
View File
@@ -326,6 +326,13 @@ func (s *Service) CompleteWithContext(ticketID, newPassword, browserContext stri
return ErrRecoveryDenied
}
}
if item.Method == "webauthn" && item.CredentialID > 0 {
var credential models.WebAuthnCredential
found, lookupErr := s.engine.Where("id = ? AND user_id = ? AND revoked_at IS NULL", item.CredentialID, item.UserID).Get(&credential)
if lookupErr != nil || !found {
return ErrRecoveryDenied
}
}
version := user.SessionVersion + 1
if version <= 0 {
version = 1