fixed GetTOTP, started rough QR code implementation
GetTOTP handles TOTP method retrieval for confirmation and deletion. QR code implementation looks like it's gonna suck, so might end up using a library for this later.
This commit is contained in:
parent
ad39e68cd6
commit
1edc051ae2
5 changed files with 132 additions and 13 deletions
|
@ -64,9 +64,9 @@ func GenerateTOTPURI(username string, secret string) string {
|
|||
query := url.Query()
|
||||
query.Set("secret", secret)
|
||||
query.Set("issuer", "arimelody.me")
|
||||
query.Set("algorithm", "SHA1")
|
||||
query.Set("digits", fmt.Sprintf("%d", TOTP_CODE_LENGTH))
|
||||
query.Set("period", fmt.Sprintf("%d", TOTP_TIME_STEP))
|
||||
// query.Set("algorithm", "SHA1")
|
||||
// query.Set("digits", fmt.Sprintf("%d", TOTP_CODE_LENGTH))
|
||||
// query.Set("period", fmt.Sprintf("%d", TOTP_TIME_STEP))
|
||||
url.RawQuery = query.Encode()
|
||||
|
||||
return url.String()
|
||||
|
@ -116,8 +116,9 @@ func GetTOTP(db *sqlx.DB, accountID string, name string) (*model.TOTP, error) {
|
|||
err := db.Get(
|
||||
&totp,
|
||||
"SELECT * FROM totp " +
|
||||
"WHERE account=$1",
|
||||
"WHERE account=$1 AND name=$2",
|
||||
accountID,
|
||||
name,
|
||||
)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "no rows") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue