Skip to content

Commit

Permalink
fix user signup issue with case (in)sensitivity
Browse files Browse the repository at this point in the history
fixes #357
  • Loading branch information
BuckarooBanzay committed Jul 22, 2024
1 parent 72cc70f commit 6c990df
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions app/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ func (a *App) CreateUser(username, password string, overwrite bool, privs []stri
return nil, fmt.Errorf("password is empty")
}

auth_entry, err := a.DBContext.Auth.GetByUsername(username)
auth_entries, err := a.DBContext.Auth.Search(&dbauth.AuthSearch{UsernameIgnoreCase: &username})
if err != nil {
return nil, fmt.Errorf("could not fetch auth entry: %v", err)
}
if len(auth_entries) > 1 {
return nil, fmt.Errorf("multiple users found")
}

if auth_entry == nil {
var auth_entry *dbauth.AuthEntry
if len(auth_entries) == 0 {
// create new auth entry
salt, verifier, err := auth.CreateAuth(username, password)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/gorilla/mux v1.8.1
github.com/gorilla/websocket v1.5.3
github.com/minetest-go/dbutil v1.3.0
github.com/minetest-go/mtdb v1.1.50
github.com/minetest-go/mtdb v1.1.51
github.com/oschwald/geoip2-golang v1.11.0
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.9.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ github.com/minetest-go/mtdb v1.1.49 h1:7r9eerQbSB14S8hJoTh6S2eDwOPCRhcphTUeLqs8g
github.com/minetest-go/mtdb v1.1.49/go.mod h1:vsr1+/LcH8tbROXF40qWcuhmjoG2oIAkD1Wt+2sMR0s=
github.com/minetest-go/mtdb v1.1.50 h1:eulmUuRX5lk3L2WVRYMM7pPshdT4tgzARWf4nScpA30=
github.com/minetest-go/mtdb v1.1.50/go.mod h1:vsr1+/LcH8tbROXF40qWcuhmjoG2oIAkD1Wt+2sMR0s=
github.com/minetest-go/mtdb v1.1.51 h1:+TW7+t3+e1OZ9X468LJov5q4Fpso5XOj7fhizlWZUZk=
github.com/minetest-go/mtdb v1.1.51/go.mod h1:vsr1+/LcH8tbROXF40qWcuhmjoG2oIAkD1Wt+2sMR0s=
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs=
Expand Down

0 comments on commit 6c990df

Please sign in to comment.