aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2023-06-06 06:29:37 +0100
committerGitHub <noreply@github.com>2023-06-06 13:29:37 +0800
commit036fb7861fb8fb12f1dcabbd8edab9b322b7c96c (patch)
tree53866bb0ed5cdfc8b1c000871e4f2d6e3119cc67 /routers
parentc09f747b516f52b16f3d699e5f115789600a432a (diff)
downloadgitea-036fb7861fb8fb12f1dcabbd8edab9b322b7c96c.tar.gz
gitea-036fb7861fb8fb12f1dcabbd8edab9b322b7c96c.zip
Clean up WebAuthn javascript code and remove JQuery code (#22697)
There were several issues with the WebAuthn registration and testing code and the style was very old javascript with jquery callbacks. This PR uses async and fetch to replace the JQuery code. Ref #22651 Signed-off-by: Andrew Thornton <art27@cantab.net> --------- Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: silverwind <me@silverwind.io>
Diffstat (limited to 'routers')
-rw-r--r--routers/web/user/setting/security/webauthn.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/routers/web/user/setting/security/webauthn.go b/routers/web/user/setting/security/webauthn.go
index 0054318867..826562f157 100644
--- a/routers/web/user/setting/security/webauthn.go
+++ b/routers/web/user/setting/security/webauthn.go
@@ -6,6 +6,8 @@ package security
import (
"errors"
"net/http"
+ "strconv"
+ "time"
"code.gitea.io/gitea/models/auth"
wa "code.gitea.io/gitea/modules/auth/webauthn"
@@ -23,8 +25,8 @@ import (
func WebAuthnRegister(ctx *context.Context) {
form := web.GetForm(ctx).(*forms.WebauthnRegistrationForm)
if form.Name == "" {
- ctx.Error(http.StatusConflict)
- return
+ // Set name to the hexadecimal of the current time
+ form.Name = strconv.FormatInt(time.Now().UnixNano(), 16)
}
cred, err := auth.GetWebAuthnCredentialByName(ctx.Doer.ID, form.Name)