github.com/volatiletech/authboss@v2.4.1+incompatible/otp/twofactor/totp2fa/totp_payloads.go (about) 1 package totp2fa 2 3 import ( 4 "fmt" 5 6 "github.com/volatiletech/authboss" 7 ) 8 9 // TOTPCodeValuer returns a code from the body 10 type TOTPCodeValuer interface { 11 authboss.Validator 12 13 GetCode() string 14 GetRecoveryCode() string 15 } 16 17 // MustHaveTOTPCodeValues upgrades a validatable set of values 18 // to ones specific to a user that needs to be recovered. 19 func MustHaveTOTPCodeValues(v authboss.Validator) TOTPCodeValuer { 20 if u, ok := v.(TOTPCodeValuer); ok { 21 return u 22 } 23 24 panic(fmt.Sprintf("bodyreader returned a type that could not be upgraded to TOTPCodeValuer: %T", v)) 25 }