Pad GPG Key ID with preceding zeroes (#20878)
This commit is contained in:
parent
0ee96da052
commit
11bae50484
4 changed files with 24 additions and 8 deletions
|
@ -7,6 +7,7 @@ package user
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
asymkey_model "code.gitea.io/gitea/models/asymkey"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
|
@ -177,6 +178,12 @@ func VerifyUserGPGKey(ctx *context.APIContext) {
|
|||
token := asymkey_model.VerificationToken(ctx.Doer, 1)
|
||||
lastToken := asymkey_model.VerificationToken(ctx.Doer, 0)
|
||||
|
||||
form.KeyID = strings.TrimLeft(form.KeyID, "0")
|
||||
if form.KeyID == "" {
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
||||
_, err := asymkey_model.VerifyGPGKey(ctx.Doer.ID, form.KeyID, token, form.Signature)
|
||||
if err != nil && asymkey_model.IsErrGPGInvalidTokenSignature(err) {
|
||||
_, err = asymkey_model.VerifyGPGKey(ctx.Doer.ID, form.KeyID, lastToken, form.Signature)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue