From 1aad1ef3593b338a8ed6e02e5a173ad8a849e2d5 Mon Sep 17 00:00:00 2001 From: Dikiy13371 Date: Tue, 7 Oct 2025 23:29:43 +0300 Subject: [PATCH] new user.go v2.0 --- database/model/user.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/database/model/user.go b/database/model/user.go index 5eebea2b..9c88b4c1 100644 --- a/database/model/user.go +++ b/database/model/user.go @@ -1,15 +1,11 @@ package model -import ( - "time" -) - -// User represents a panel user with RBAC role. +// ВАЖНО: имена полей ДОЛЖНЫ остаться такими, +// потому что их использует остальной код: Id, Username, PasswordHash, Role. type User struct { - ID int `json:"id" gorm:"primaryKey;autoIncrement"` - Email string `json:"email" gorm:"unique;not null"` - Password string `json:"-" gorm:"not null"` - Role string `json:"role" gorm:"default:'reader'"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` + Id int `json:"id" gorm:"primaryKey;autoIncrement"` + Username string `json:"username" gorm:"uniqueIndex;not null"` + Password string `json:"-"` // может использоваться для приема сырого пароля (не храним) + PasswordHash string `json:"-" gorm:"column:password_hash"` + Role string `json:"role" gorm:"not null"` // admin | moder | reader }