Download internal/models/user.go from Collabos/registar: direct link, hf CLI and curl.
- Browser
- Download file 3.72 kB
-
https://huggingface.co/spaces/Collabos/registar/resolve/main/internal/models/user.go
- Command line
-
hf download hf://spaces/Collabos/registar/internal/models/user.go
-
curl -L -o user.go https://huggingface.co/spaces/Collabos/registar/resolve/main/internal/models/user.go
3.72 kB
| package models | |
| import "time" | |
| // User is the full MongoDB document. | |
| // Fields tagged json:"-" are NEVER serialised over the wire. | |
| type User struct { | |
| UID string `bson:"uid" json:"uid"` | |
| Name string `bson:"name" json:"name"` // user-provided | |
| Username string `bson:"username" json:"username"` | |
| Email string `bson:"email" json:"email,omitempty"` | |
| Bio string `bson:"bio" json:"bio"` // user-provided, nullable | |
| ProfilePic string `bson:"profile_pic" json:"profile_pic"` // user-provided / OAuth avatar | |
| Status string `bson:"status" json:"status"` // user-provided, nullable | |
| Location string `bson:"location" json:"location"` // user-provided, nullable | |
| Gender string `bson:"gender" json:"gender"` // user-provided, nullable | |
| Timezone string `bson:"timezone" json:"timezone"` // user-provided / browser | |
| // Auto-collected — never prompted, always set by server | |
| SignupType string `bson:"signup_type" json:"signup_type"` // google|github|email | |
| Provider string `bson:"provider" json:"provider"` | |
| ProviderID string `bson:"provider_id" json:"-"` | |
| OAuthToken string `bson:"oauth_token" json:"-"` | |
| PasswordHash string `bson:"password_hash" json:"-"` | |
| IP string `bson:"ip" json:"-"` // stored, never returned | |
| UserAgent string `bson:"user_agent" json:"-"` | |
| DeviceInfo string `bson:"device_info" json:"-"` // JSON blob from browser | |
| CreatedAt time.Time `bson:"created_at" json:"created_at"` | |
| UpdatedAt time.Time `bson:"updated_at" json:"updated_at"` | |
| LastSeen time.Time `bson:"last_seen" json:"last_seen"` | |
| } | |
| // Public is the safe subset returned over the data pipe and after login. | |
| type Public struct { | |
| UID string `json:"uid"` | |
| Name string `json:"name"` | |
| Username string `json:"username"` | |
| Email string `json:"email,omitempty"` | |
| Bio string `json:"bio"` | |
| ProfilePic string `json:"profile_pic"` | |
| Status string `json:"status"` | |
| Location string `json:"location"` | |
| Gender string `json:"gender"` | |
| Timezone string `json:"timezone"` | |
| SignupType string `json:"signup_type"` | |
| CreatedAt time.Time `json:"created_at"` | |
| LastSeen time.Time `json:"last_seen"` | |
| } | |
| // LoginResult is what the auth pipe sends back on success. | |
| type LoginResult struct { | |
| UID string `json:"uid"` | |
| Token string `json:"token"` // signed JWT (7 days) | |
| IsNew bool `json:"is_new"` | |
| User Public `json:"user"` | |
| } | |
| func (u User) ToPublic() Public { | |
| return Public{ | |
| UID: u.UID, | |
| Name: u.Name, | |
| Username: u.Username, | |
| Email: u.Email, | |
| Bio: u.Bio, | |
| ProfilePic: u.ProfilePic, | |
| Status: u.Status, | |
| Location: u.Location, | |
| Gender: u.Gender, | |
| Timezone: u.Timezone, | |
| SignupType: u.SignupType, | |
| CreatedAt: u.CreatedAt, | |
| LastSeen: u.LastSeen, | |
| } | |
| } | |
| // UserData is the struct for user-submitted profile fields. | |
| // All fields are optional — frontend sends nulls for unset fields. | |
| type UserData struct { | |
| Name *string `json:"name"` | |
| Bio *string `json:"bio"` | |
| ProfilePic *string `json:"profile_pic"` | |
| Status *string `json:"status"` | |
| Location *string `json:"location"` | |
| Gender *string `json:"gender"` | |
| Timezone *string `json:"timezone"` | |
| } | |
| // DeviceInfo is collected by the frontend and sent at login/signup. | |
| type DeviceInfo struct { | |
| UA string `json:"ua"` | |
| Platform string `json:"platform"` | |
| Screen string `json:"screen"` | |
| Lang string `json:"lang"` | |
| TZ string `json:"tz"` | |
| } | |