Documentation
¶
Overview ¶
Package model defines all the models.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DummyCheckPassword ¶
func DummyCheckPassword()
DummyCheckPassword is a fake password check to prevent timing attacks.
Types ¶
type Auth ¶
type Auth struct { ID string `json:"id" valid:"-"` Method Method `json:"method" valid:"-"` Values []string `json:"values" valid:"-"` }
Auth represents a form of authentication for the link.
type Link ¶
type Link struct { Slug string `json:"slug" valid:"stringlength(6|10),required"` Title string `json:"title" valid:"required"` URL string `json:"url" valid:"url,required"` Created time.Time `json:"created" valid:"-"` Count int `json:"count" valid:"-"` AuthIDs []string `json:"auth_ids" valid:"-"` }
Link represents a shortened link.
type Method ¶
type Method int
Method is a method of authentication (e.g. Google, GitHub or password).
type User ¶
type User struct { Username string `json:"username" valid:"stringlength(2|20)"` Registered bool `json:"registered" valid:"-"` Email string `json:"email" valid:"email,required"` Password string `json:"password" valid:"-"` Joined time.Time `json:"joined" valid:"-"` LastVisit time.Time `json:"last_visit" valid:"-"` LinkSlugs []string `json:"link_slugs" valid:"-"` }
User represents a registered user.
func NewAnonymousUser ¶
func NewAnonymousUser() *User
NewAnonymousUser creates a new anonymous user.
Username is a random alphabetic string.
func (*User) CheckPassword ¶
CheckPassword checks whether the given password is correct.
func (*User) FindLinkSlug ¶
FindLinkSlug searches for a slug that belongs to the user and returns its index and flag to indicate whether it exists.
func (*User) SetPassword ¶
SetPassword ensures the passwords are equal, generates the hash and then sets it on the user.