aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAKP <tom@tdpain.net>2022-04-01 20:19:29 +0100
committerAKP <tom@tdpain.net>2022-04-01 20:19:29 +0100
commit5b1336c229ffbb26eb17b611fab3ccfe17e2d3c6 (patch)
tree81591fd8a46425cc397580040e75aa7e7d9f6c55
parente03d17ffbebebba0c5f0468addf8349c2336c437 (diff)
Fix constraints on User
Having both `boltholdUnique` and `boltholdIndex` on one type made neither work properly Signed-off-by: AKP <tom@tdpain.net>
-rw-r--r--walrss/internal/core/users.go2
-rw-r--r--walrss/internal/db/db.go6
2 files changed, 3 insertions, 5 deletions
diff --git a/walrss/internal/core/users.go b/walrss/internal/core/users.go
index f909a1d..dfc3635 100644
--- a/walrss/internal/core/users.go
+++ b/walrss/internal/core/users.go
@@ -31,7 +31,7 @@ func RegisterUser(st *state.State, email, password string) (*db.User, error) {
u.Password = hash
- if err := st.Data.Insert(bh.Key, u); err != nil {
+ if err := st.Data.Insert(u.ID, u); err != nil {
if errors.Is(err, bh.ErrUniqueExists) {
return nil, NewUserError("email address in use")
}
diff --git a/walrss/internal/db/db.go b/walrss/internal/db/db.go
index efb3f46..d9769e7 100644
--- a/walrss/internal/db/db.go
+++ b/walrss/internal/db/db.go
@@ -1,8 +1,6 @@
package db
-import (
- bh "github.com/timshannon/bolthold"
-)
+import bh "github.com/timshannon/bolthold"
func New(filename string) (*bh.Store, error) {
store, err := bh.Open(filename, 0644, nil)
@@ -14,7 +12,7 @@ func New(filename string) (*bh.Store, error) {
type User struct {
ID string `boldholdKey:""`
- Email string `boltholdUnique:"UniqueEmail" boltholdIndex:"Email"`
+ Email string `boltholdUnique:"UniqueEmail"`
Password []byte
Salt []byte