identity

package
v0.0.0-...-d1a64ea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2016 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccountTypeNormalUser    = iota
	AccountTypeAdministrator = iota
)

Constants describing the type of account the the users have

View Source
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

func DeleteUser(userID bson.ObjectId) error

DeleteUser deletes an ApplicationUser from the database, based on its ID

func IsUserActivated

func IsUserActivated(userID bson.ObjectId) bool

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

type Identity struct {
	Session *cookies.Session
	// contains filtered or unexported fields
}

Identity represents the identity of the user the is in the current context

func New

func New(session *cookies.Session) *Identity

New creates a new Identity based on a user session

func NewAnonymous

func NewAnonymous() *Identity

NewAnonymous creates a new anonymous Identity, with no user session defined

func (*Identity) IsAdmin

func (identity *Identity) IsAdmin() bool

IsAdmin returns true if the current authorized user is in the admin role

func (*Identity) IsAnonymous

func (identity *Identity) IsAnonymous() bool

IsAnonymous returns true if the current user is anonymous

func (*Identity) IsAuthorized

func (identity *Identity) IsAuthorized() bool

IsAuthorized returns true if the user is authorized

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL