Remove DisabledAt for users

This commit is contained in:
William Bouzourène 2025-01-02 19:50:14 +01:00
parent fa3aa49419
commit 7d71923d4f
Signed by: bouzoure
SSH key fingerprint: SHA256:19MbXpLua4rUtk8tunMesD8KUKb91LXLHg8E/qTooww
3 changed files with 2 additions and 10 deletions

View file

@ -3,7 +3,6 @@ package controllers
import ( import (
"errors" "errors"
"fmt" "fmt"
"time"
"git.readonly.ch/bouzoure/popvaud-people/helpers" "git.readonly.ch/bouzoure/popvaud-people/helpers"
"git.readonly.ch/bouzoure/popvaud-people/models" "git.readonly.ch/bouzoure/popvaud-people/models"
@ -33,12 +32,7 @@ func LoginForm(c *fiber.Ctx) error {
password := c.FormValue("password") password := c.FormValue("password")
var user models.User var user models.User
result := db.First( result := db.First(&user, "LOWER(email) = LOWER(?)", email)
&user,
"LOWER(email) = LOWER(?) AND (disabled_at IS NULL OR disabled_at <= ?)",
email,
time.Now(),
)
if result.Error != nil && !errors.Is(result.Error, gorm.ErrRecordNotFound) { if result.Error != nil && !errors.Is(result.Error, gorm.ErrRecordNotFound) {
return err return err

View file

@ -3,7 +3,6 @@ package helpers
import ( import (
"errors" "errors"
"fmt" "fmt"
"time"
"git.readonly.ch/bouzoure/popvaud-people/models" "git.readonly.ch/bouzoure/popvaud-people/models"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
@ -63,7 +62,7 @@ func UserExistsAndIsActive(id uint) (bool, error) {
} }
var user models.User var user models.User
result := db.First(&user, "id = ? AND (disabled_at IS NULL OR disabled_at <= ?)", id, time.Now()) result := db.First(&user, "id = ?", id)
if errors.Is(result.Error, gorm.ErrRecordNotFound) { if errors.Is(result.Error, gorm.ErrRecordNotFound) {
return false, nil return false, nil

View file

@ -12,7 +12,6 @@ type User struct {
Email string Email string
Password string Password string
TotpSercet sql.NullString TotpSercet sql.NullString
DisabledAt sql.NullTime
IsAdmin bool IsAdmin bool
SkipWelcome bool SkipWelcome bool
} }