diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 4ab9e55..d299f91 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,10 +4,12 @@
-
+
-
-
+
+
+
+
@@ -140,7 +142,8 @@
-
+
+
true
diff --git a/pkg/server/auth_api.go b/pkg/server/auth_api.go
index 8250cb9..528b7db 100644
--- a/pkg/server/auth_api.go
+++ b/pkg/server/auth_api.go
@@ -118,7 +118,7 @@ func getToken(c *fiber.Ctx) error {
if err != nil {
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("invalid password: %v", err.Error()))
} else if err := ticket.IsAvailable(); err != nil {
- return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("risk detected: %v", err))
+ return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("risk detected: %v (ticketId=%d)", err, ticket.ID))
}
access, refresh, err = services.ExchangeOauthToken(data.ClientID, data.ClientSecret, data.RedirectUri, *ticket.GrantToken)
if err != nil {
diff --git a/pkg/services/ticket.go b/pkg/services/ticket.go
index 194661c..f6d6d19 100644
--- a/pkg/services/ticket.go
+++ b/pkg/services/ticket.go
@@ -12,11 +12,21 @@ import (
)
func DetectRisk(user models.Account, ip, ua string) bool {
+ var availableFactor int64
+ if err := database.C.
+ Where(models.AuthFactor{AccountID: user.ID}).
+ Where("type != ?", models.PasswordAuthFactor).
+ Model(models.AuthFactor{}).
+ Where(&availableFactor); err != nil || availableFactor <= 0 {
+ return false
+ }
+
var secureFactor int64
- if err := database.C.Where(models.AuthTicket{
- AccountID: user.ID,
- IpAddress: ip,
- }).Model(models.AuthTicket{}).Count(&secureFactor).Error; err == nil {
+ if err := database.C.
+ Where(models.AuthTicket{AccountID: user.ID, IpAddress: ip}).
+ Where("available_at IS NOT NULL").
+ Model(models.AuthTicket{}).
+ Count(&secureFactor).Error; err == nil {
if secureFactor >= 1 {
return false
}
diff --git a/pkg/views/partials/header.gohtml b/pkg/views/partials/header.gohtml
index fcba8b1..8f6349f 100644
--- a/pkg/views/partials/header.gohtml
+++ b/pkg/views/partials/header.gohtml
@@ -83,6 +83,7 @@
html, body {
padding: 0;
margin: 0;
+ background-color: var(--md-sys-color-surface-container);
}
diff --git a/pkg/views/users/personalize.gohtml b/pkg/views/users/personalize.gohtml
index 0c9e2d6..b52c439 100644
--- a/pkg/views/users/personalize.gohtml
+++ b/pkg/views/users/personalize.gohtml
@@ -8,9 +8,13 @@