25 lines
954 B
Go
25 lines
954 B
Go
// Package models contains the application's domain types (plain data
|
|||
|
|
// structs like User) and their repositories (the code that knows how to
|
||
|
|
// load/save them from/to the database).
|
||
|
|
package models
|
||
|
|
|
||
|
|
import "time"
|
||
|
|
|
||
|
|
// User represents one account in our system. It can be authenticated in
|
||
|
|
// two different ways, both represented on the same row:
|
||
|
|
// - Password login: PasswordHash is set, GoogleID is empty.
|
||
|
|
// - Google login: GoogleID is set, PasswordHash is empty.
|
||
|
|
// - Both: a password user later links a Google account (or
|
||
|
|
// vice versa), and both fields end up populated.
|
||
|
|
//
|
||
|
|
// Deliberately NOT included here: a plaintext Password field. This struct
|
||
|
|
// should never hold a plaintext password in memory beyond the brief moment
|
||
|
|
// it's hashed during registration - see handlers.Register.
|
||
|
|
type User struct {
|
||
|
|
ID int
|
||
|
|
Email string
|
||
|
|
PasswordHash string
|
||
|
|
GoogleID string
|
||
|
|
CreatedAt time.Time
|
||
|
|
}
|