Documentation ¶
Index ¶
- Constants
- func CreateUser(user *ApplicationUser) error
- func DeleteUser(userID bson.ObjectId) error
- func IsUserActivated(userID bson.ObjectId) bool
- func UpdateUser(user *ApplicationUser) error
- type ApplicationUser
- func GetUser(userID bson.ObjectId) (*ApplicationUser, error)
- func GetUserByActivationToken(token string) (*ApplicationUser, error)
- func GetUserByEmail(emailAddress string) (*ApplicationUser, error)
- func GetUserByResetPasswordToken(token string) (*ApplicationUser, error)
- func IsUserExistent(userID bson.ObjectId) (*ApplicationUser, bool)
- type Identity
Constants ¶
const ( AccountTypeNormalUser = iota AccountTypeAdministrator = iota )
Constants describing the type of account the the users have
const ( AccountStatusDeactivated = iota AccountStatusActivated = iota )
Constants describing the status of the current user account
Variables ¶
This section is empty.
Functions ¶
func CreateUser ¶
func CreateUser(user *ApplicationUser) error
CreateUser adds a new ApplicationUser to the database
func DeleteUser ¶
DeleteUser deletes an ApplicationUser from the database, based on its ID
func IsUserActivated ¶
IsUserActivated verifies if an user account is activated
func UpdateUser ¶
func UpdateUser(user *ApplicationUser) error
UpdateUser updates an existing ApplicationUser in the database
Types ¶
type ApplicationUser ¶
type ApplicationUser struct { ID bson.ObjectId `bson:"_id" json:"id"` Email string `bson:"email,omitempty" json:"email"` Password string `bson:"password,omitempty" json:"password"` AccountType int `bson:"accountType,omitempty" json:"accountType"` ResetPasswordToken string `bson:"resetPasswordToken,omitempty" json:"resetPasswordToken"` ResetPasswordTokenExpireDate time.Time `bson:"resetPasswordTokenExpireDate,omitempty" json:"resetPasswordTokenExpireDate"` ActivateAccountToken string `bson:"activateAccountToken" json:"activateAccountToken"` ActivateAccountTokenExpireDate time.Time `bson:"activateAccountTokenExpireDate,omitempty" json:"activateAccountTokenExpireDate"` AccountStatus int `bson:"accountStatus,omitempty" json:"accountStatus"` }
ApplicationUser contains information necessary for managing accounts
func GetUser ¶
func GetUser(userID bson.ObjectId) (*ApplicationUser, error)
GetUser retrieves an ApplicationUser from the database, based on its ID
func GetUserByActivationToken ¶
func GetUserByActivationToken(token string) (*ApplicationUser, error)
GetUserByActivationToken retrieves an ApplicationUser from the database, based on its account activation token
func GetUserByEmail ¶
func GetUserByEmail(emailAddress string) (*ApplicationUser, error)
GetUserByEmail retrieves an ApplicationUser from the database, based on its email address
func GetUserByResetPasswordToken ¶
func GetUserByResetPasswordToken(token string) (*ApplicationUser, error)
GetUserByResetPasswordToken retrieves an ApplicationUser from the database, based on its reset password token
func IsUserExistent ¶
func IsUserExistent(userID bson.ObjectId) (*ApplicationUser, bool)
IsUserExistent verifies if an user with the given id exists
type Identity ¶
Identity represents the identity of the user the is in the current context
func NewAnonymous ¶
func NewAnonymous() *Identity
NewAnonymous creates a new anonymous Identity, with no user session defined
func (*Identity) IsAnonymous ¶
IsAnonymous returns true if the current user is anonymous
func (*Identity) IsAuthorized ¶
IsAuthorized returns true if the user is authorized