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>
This commit is contained in:
parent
c09f747b51
commit
036fb7861f
9 changed files with 191 additions and 164 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue