feat: totp close #9

This commit is contained in:
naiba
2021-01-04 21:46:18 +08:00
committed by dushixiang
parent 2d160c70f9
commit 3bf8fe6684
11 changed files with 213 additions and 49 deletions

19
pkg/totp/totp.go Normal file
View File

@ -0,0 +1,19 @@
package totp
import (
otp_t "github.com/pquerna/otp"
totp_t "github.com/pquerna/otp/totp"
)
type GenerateOpts totp_t.GenerateOpts
func NewTOTP(opt GenerateOpts) (*otp_t.Key, error) {
return totp_t.Generate(totp_t.GenerateOpts(opt))
}
func Validate(code string, secret string) bool {
if secret == "" {
return true
}
return totp_t.Validate(code, secret)
}