新增修改注册流程

This commit is contained in:
zyj
2025-09-30 11:19:39 +08:00
parent 22e21f6eb8
commit dbf8b5bcca
9 changed files with 391 additions and 42 deletions

View File

@@ -2,7 +2,10 @@ package utils
import (
"math/rand"
"strings"
"time"
"github.com/pquerna/otp/totp"
)
type RandDateParams struct {
@@ -73,3 +76,18 @@ func RandDate(minAge, maxAge int) RandDateParams {
Day: day,
}
}
// 获取FA2码
func GetFA2Code(secret string) (string, error) {
// 去除多余的字符串
replacer := strings.NewReplacer(
"-", "",
" ", "",
)
result := replacer.Replace(secret)
code, err := totp.GenerateCode(result, time.Now())
if err != nil {
return "", err
}
return code, nil
}