new user.go v2.0

This commit is contained in:
Dikiy13371 2025-10-07 23:29:43 +03:00
parent 0e28f2b178
commit 1aad1ef359

View file

@ -1,15 +1,11 @@
package model package model
import ( // ВАЖНО: имена полей ДОЛЖНЫ остаться такими,
"time" // потому что их использует остальной код: Id, Username, PasswordHash, Role.
)
// User represents a panel user with RBAC role.
type User struct { type User struct {
ID int `json:"id" gorm:"primaryKey;autoIncrement"` Id int `json:"id" gorm:"primaryKey;autoIncrement"`
Email string `json:"email" gorm:"unique;not null"` Username string `json:"username" gorm:"uniqueIndex;not null"`
Password string `json:"-" gorm:"not null"` Password string `json:"-"` // может использоваться для приема сырого пароля (не храним)
Role string `json:"role" gorm:"default:'reader'"` PasswordHash string `json:"-" gorm:"column:password_hash"`
CreatedAt time.Time `json:"created_at"` Role string `json:"role" gorm:"not null"` // admin | moder | reader
UpdatedAt time.Time `json:"updated_at"`
} }