Documentation ¶
Index ¶
Constants ¶
View Source
const ( // ScopeActivation is used to generate an activation token. ScopeActivation string = "activation" // ScopeAuthentication is used to generate an authentication token. ScopeAuthentication string = "authentication" )
Variables ¶
View Source
var ( // ErrDuplicateKey is returned when a record with duplicate values is attempted to be inserted into the database. ErrDuplicateKey = errors.New("username and or email already taken") // ErrRecordNotFound is returned when a find database query returns no record. ErrRecordNotFound = errors.New("record not found") // ErrInvalidOrExpiredToken is returned when token find query returns no record. ErrInvalidOrExpiredToken = errors.New("invalid or expired token") // ErrInvalidProperty is returned when user activation data contains invalid properties. ErrInvalidProperty = errors.New("Invalid property") )
View Source
var AnonymousUser = &User{}
AnonymousUser represents a user type instance with only defaults.
View Source
var EmailRegex = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
EmailRegex represents an email regular expression.
Functions ¶
func ValidateEmail ¶
ValidateEmail validates an email address.
func ValidatePassword ¶
ValidatePassword validates a password.
func ValidatePlainTextToken ¶
ValidatePlainTextToken checks that the plaintext token is provided and is exactly 52 bytes long
Types ¶
type Password ¶
Password represents a password type model.
type Token ¶
type Token struct { ID string `json:"-,omitempty" bson:"_id,omitempty"` PlainText string `json:"token" bson:"-"` Hash []byte `json:"-"` UserID string `json:"-" bson:"user_id"` Expiry time.Time `json:"expiry" bson:"expiry,omitempty"` Scope string `json:"-"` }
Token encapsulates data for an individual token.
type User ¶
type User struct { ID string `json:"_id,omitempty" bson:"_id,omitempty"` Username string `json:"username" bson:"username"` Email string `json:"email" bson:"email"` Password Password `json:"-" bson:"password"` IsActive bool `json:"is_active" bson:"isactive"` IsSeller bool `json:"is_seller" bson:"isseller"` Version int64 `json:"version" bson:"version"` CreatedAt time.Time `json:"created_at" bson:"created_at"` }
User represents the user type model.
func (*User) IsAnonymous ¶
IsAnonymous performs an equality check on a user instance to verify if it's an anonymous user.
Click to show internal directories.
Click to hide internal directories.