增加弹窗输入OTP动态码的功能

This commit is contained in:
wsczx
2024-10-07 17:11:56 +08:00
parent 1c6fc446c9
commit 11bd9861e5
6 changed files with 288 additions and 67 deletions

View File

@@ -117,13 +117,13 @@ func checkLocalUser(name, pwd, group string) error {
}
// 判断otp信息
pinCode := pwd
if !v.DisableOtp {
pinCode = pwd[:pl-6]
otp := pwd[pl-6:]
if !checkOtp(name, otp, v.OtpSecret) {
return fmt.Errorf("%s %s", name, "动态码错误")
}
}
// if !v.DisableOtp {
// pinCode = pwd[:pl-6]
// otp := pwd[pl-6:]
// if !CheckOtp(name, otp, v.OtpSecret) {
// return fmt.Errorf("%s %s", name, "动态码错误")
// }
// }
// 判断用户密码
if pinCode != v.PinCode {
@@ -171,7 +171,7 @@ func init() {
}
// 判断令牌信息
func checkOtp(name, otp, secret string) bool {
func CheckOtp(name, otp, secret string) bool {
key := fmt.Sprintf("%s:%s", name, otp)
userOtpMux.Lock()