Remove DisabledAt for users

This commit is contained in:
William Bouzourène 2025-01-02 19:50:14 +01:00
parent 9da9cd4f61
commit 157c33227e
3 changed files with 2 additions and 10 deletions

View file

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

View file

@ -3,7 +3,6 @@ package helpers
import (
"errors"
"fmt"
"time"
"git.readonly.ch/bouzoure/popvaud-people/models"
"github.com/gofiber/fiber/v2"
@ -63,7 +62,7 @@ func UserExistsAndIsActive(id uint) (bool, error) {
}
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) {
return false, nil

View file

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