feat(07-02): add user session schema, throttle table, and jwt config

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jakub Zych
2026-09-22 13:53:16 +02:00
parent 79e8373560
commit 1311bd6cad
8 changed files with 235 additions and 11 deletions

22
models/throttle.go Normal file
View File

@@ -0,0 +1,22 @@
package models
import "time"
// Throttle is one failed-login counter, keyed by user and optional IP.
type Throttle struct {
ID uint `gorm:"column:id;primaryKey"`
UserID uint `gorm:"column:user_id"`
IPAddress *string `gorm:"column:ip_address"`
Attempts int `gorm:"column:attempts"`
IsSuspended bool `gorm:"column:is_suspended"`
SuspendedAt *time.Time `gorm:"column:suspended_at"`
IsBanned bool `gorm:"column:is_banned"`
CreatedAt time.Time `gorm:"column:created_at"`
UpdatedAt time.Time `gorm:"column:updated_at"`
}
func (Throttle) TableName() string { return "user_throttle" }
func init() {
Register(Throttle{})
}