mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-04 16:50:27 +00:00
make login case insensitive
This commit is contained in:
parent
7b28973c60
commit
6c2d1fd60f
2 changed files with 3 additions and 2 deletions
|
@ -3,6 +3,7 @@ package v1
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hay-kot/homebox/backend/internal/core/services"
|
"github.com/hay-kot/homebox/backend/internal/core/services"
|
||||||
|
@ -70,7 +71,7 @@ func (ctrl *V1Controller) HandleAuthLogin() server.HandlerFunc {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
newToken, err := ctrl.svc.User.Login(r.Context(), loginForm.Username, loginForm.Password)
|
newToken, err := ctrl.svc.User.Login(r.Context(), strings.ToLower(loginForm.Username), loginForm.Password)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return validate.NewRequestError(errors.New("authentication failed"), http.StatusInternalServerError)
|
return validate.NewRequestError(errors.New("authentication failed"), http.StatusInternalServerError)
|
||||||
|
|
|
@ -69,7 +69,7 @@ func (e *UserRepository) GetOneId(ctx context.Context, id uuid.UUID) (UserOut, e
|
||||||
|
|
||||||
func (e *UserRepository) GetOneEmail(ctx context.Context, email string) (UserOut, error) {
|
func (e *UserRepository) GetOneEmail(ctx context.Context, email string) (UserOut, error) {
|
||||||
return mapUserOutErr(e.db.User.Query().
|
return mapUserOutErr(e.db.User.Query().
|
||||||
Where(user.Email(email)).
|
Where(user.EmailEqualFold(email)).
|
||||||
WithGroup().
|
WithGroup().
|
||||||
Only(ctx),
|
Only(ctx),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue