1
0
mirror of https://github.com/nbd-wtf/satdress.git synced 2024-11-13 17:30:35 +00:00

enforce lowercase.

This commit is contained in:
fiatjaf 2021-08-21 13:52:21 -03:00
parent d79d5351ff
commit e2945ff375

4
db.go
View File

@ -7,6 +7,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"strings"
"github.com/cockroachdb/pebble" "github.com/cockroachdb/pebble"
) )
@ -21,6 +22,7 @@ type Params struct {
} }
func SaveName(name string, params *Params, providedPin string) (pin string, err error) { func SaveName(name string, params *Params, providedPin string) (pin string, err error) {
name = strings.ToLower(name)
key := []byte(name) key := []byte(name)
mac := hmac.New(sha256.New, []byte(s.Secret)) mac := hmac.New(sha256.New, []byte(s.Secret))
@ -49,6 +51,8 @@ func SaveName(name string, params *Params, providedPin string) (pin string, err
} }
func GetName(name string) (*Params, error) { func GetName(name string) (*Params, error) {
name = strings.ToLower(name)
val, closer, err := db.Get([]byte(name)) val, closer, err := db.Get([]byte(name))
if err != nil { if err != nil {
return nil, err return nil, err