package models import "time" // User represents the auth_user table. Identity — credentials, email // verification, sessions, social sign-in — is owned by Ory Kratos (phase 2). // This row is honeyDue's local mirror of a Kratos identity, linked by // KratosID; every domain table keeps its existing integer FK to auth_user.id. type User struct { ID uint `gorm:"primaryKey" json:"id"` KratosID string `gorm:"column:kratos_id;uniqueIndex;size:36" json:"-"` // Kratos identity UUID Username string `gorm:"column:username;uniqueIndex;size:150" json:"username"` FirstName string `gorm:"column:first_name;size:150" json:"first_name"` LastName string `gorm:"column:last_name;size:150" json:"last_name"` Email string `gorm:"column:email;uniqueIndex;size:254" json:"email"` IsStaff bool `gorm:"column:is_staff;default:false" json:"is_staff"` IsActive bool `gorm:"column:is_active;default:true" json:"is_active"` IsSuperuser bool `gorm:"column:is_superuser;default:false" json:"is_superuser"` DateJoined time.Time `gorm:"column:date_joined;autoCreateTime" json:"date_joined"` LastLogin *time.Time `gorm:"column:last_login" json:"last_login,omitempty"` // Relations — not columns on auth_user. Profile *UserProfile `gorm:"foreignKey:UserID" json:"profile,omitempty"` OwnedResidences []Residence `gorm:"foreignKey:OwnerID" json:"-"` SharedResidences []Residence `gorm:"many2many:residence_residence_users;" json:"-"` NotificationPref *NotificationPreference `gorm:"foreignKey:UserID" json:"-"` Subscription *UserSubscription `gorm:"foreignKey:UserID" json:"-"` } // TableName returns the table name for GORM. func (User) TableName() string { return "auth_user" } // GetFullName returns the user's display name. func (u *User) GetFullName() string { if u.FirstName != "" && u.LastName != "" { return u.FirstName + " " + u.LastName } if u.FirstName != "" { return u.FirstName } return u.Username } // UserProfile represents the user_userprofile table — honeyDue-specific // profile data, keyed to a local user. Email-verification state is owned by // Kratos; the Verified column is a convenience mirror set at provision time. type UserProfile struct { BaseModel UserID uint `gorm:"column:user_id;uniqueIndex;not null" json:"user_id"` Verified bool `gorm:"column:verified;default:false" json:"verified"` Bio string `gorm:"column:bio;type:text" json:"bio"` PhoneNumber string `gorm:"column:phone_number;size:15" json:"phone_number"` DateOfBirth *time.Time `gorm:"column:date_of_birth;type:date" json:"date_of_birth,omitempty"` ProfilePicture string `gorm:"column:profile_picture;size:100" json:"profile_picture"` // Relations User User `gorm:"foreignKey:UserID" json:"-"` } // TableName returns the table name for GORM. func (UserProfile) TableName() string { return "user_userprofile" }