diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 2bc673f..26431f1 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,11 +4,11 @@
-
-
+
-
-
+
+
+
@@ -146,7 +146,6 @@
-
@@ -171,7 +170,8 @@
-
+
+
true
diff --git a/pkg/internal/server/api/auth_api.go b/pkg/internal/server/api/auth_api.go
index dd6f546..5104dde 100644
--- a/pkg/internal/server/api/auth_api.go
+++ b/pkg/internal/server/api/auth_api.go
@@ -12,7 +12,7 @@ import (
func doAuthenticate(c *fiber.Ctx) error {
var data struct {
- Username string `json:"username"`
+ Username string `json:"username" validate:"required"`
Password string `json:"password" validate:"required"`
}
@@ -34,7 +34,7 @@ func doAuthenticate(c *fiber.Ctx) error {
ticket, err = services.ActiveTicketWithPassword(ticket, data.Password)
if err != nil {
- return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("invalid password: %v", err.Error()))
+ return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("failed to authenticate: %v", err.Error()))
}
return c.JSON(fiber.Map{
@@ -66,7 +66,7 @@ func doMultiFactorAuthenticate(c *fiber.Ctx) error {
ticket, err = services.ActiveTicketWithMFA(ticket, factor, data.Code)
if err != nil {
- return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("invalid code: %v", err.Error()))
+ return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("failed to authenticate: %v", err.Error()))
}
return c.JSON(fiber.Map{
diff --git a/pkg/internal/services/factors.go b/pkg/internal/services/factors.go
index 4a30bf8..8228dab 100644
--- a/pkg/internal/services/factors.go
+++ b/pkg/internal/services/factors.go
@@ -3,6 +3,7 @@ package services
import (
"fmt"
"github.com/samber/lo"
+ "strings"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/models"
@@ -99,7 +100,7 @@ func CheckFactor(factor models.AuthFactor, code string) error {
)
case models.EmailPasswordFactor:
return lo.Ternary(
- code == factor.Secret,
+ strings.ToUpper(code) == strings.ToUpper(factor.Secret),
nil,
fmt.Errorf("invalid verification code"),
)
diff --git a/web/src/components/auth/Authenticate.vue b/web/src/components/auth/Authenticate.vue
index 22fc05a..6056427 100755
--- a/web/src/components/auth/Authenticate.vue
+++ b/web/src/components/auth/Authenticate.vue
@@ -49,7 +49,7 @@ async function submit() {
const res = await request("/api/auth", {
method: "POST",
headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ id: probe.value, password: password.value }),
+ body: JSON.stringify({ username: probe.value, password: password.value }),
})
if (res.status !== 200) {
error.value = await res.text()