feat: 2fa via passkey

This commit is contained in:
Jacky 2024-09-16 11:18:14 +08:00
parent bdfbbd0e8f
commit 0a6a7693a1
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
21 changed files with 384 additions and 218 deletions

View file

@ -8,6 +8,7 @@ import (
"github.com/0xJacky/Nginx-UI/settings"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
"math/rand/v2"
"net/http"
"sync"
"time"
@ -67,7 +68,8 @@ func Login(c *gin.Context) {
u, err := user.Login(json.Name, json.Password)
if err != nil {
// time.Sleep(5 * time.Second)
random := time.Duration(rand.Int() % 10)
time.Sleep(random * time.Second)
switch {
case errors.Is(err, user.ErrPasswordIncorrect):
c.JSON(http.StatusForbidden, LoginResponse{