model

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const AuthTokenCollection = "authTokens"

AuthTokenCollection : collection name of the 'authToken' documents.

View Source
const ContactCollection = "contact"

ContactCollection : collection name of the 'contact' documents.

View Source
const DeletedUserCollection = "deletedUsers"

DeletedUserCollection : collection name of the 'deletedUsers' documents.

View Source
const DisabledUserCollection = "disabledUsers"

DisabledUserCollection : collection name of the 'disabledUsers' documents.

View Source
const ForgotPasswordProcessCollection = "forgotPassword"

ForgotPasswordProcessCollection : collection name of the 'forgotPassword' documents.

View Source
const IPLocationCollection = "IPLocation"

IPLocationCollection : collection name of the 'ipLocation' documents.

View Source
const NotificationCollection = "notifications"

NotificationCollection : collection name of the 'notifications' documents.

View Source
const UpdatePropertyProcessCollection = "updateProperty"

UpdatePropertyProcessCollection : collection name of the 'updateProperty' documents.

View Source
const UserCollection = "users"

UserCollection : collection name of the 'user' documents.

Variables

View Source
var (
	// UserMaxValidateRegistrationAttemps : maximum attempts to validate a registration.
	UserMaxValidateRegistrationAttemps uint = 5

	// UserMaxDescriptionLength : maximum length of the description of an account.
	UserMaxDescriptionLength uint = 300

	// UserMaxImageSize : maximum size of the image of the account (in bytes).
	UserMaxImageSize int64 = 2000000

	// UserImagePath : path of the directory containing the user images.
	UserImagePath = "/images"

	// UserImageWidth : width of the user images (in px).
	UserImageWidth int64 = 800

	// UserImageHeight : height of the user images (in px).
	UserImageHeight int64 = 800

	// UserImageSmallVersion : true if the small version of the user's image must be generated.
	UserImageSmallVersion = true

	// UserImageThumbVersion : true if the small version of the user's image must be generated.
	UserImageThumbVersion = true
)
View Source
var (
	// AllUserAbilities : all the user abilities are listed here.
	AllUserAbilities = []string{
		rights.AbilityToManageUsers,
		rights.AbilityToManageContacts,
	}

	// DefaultUserAbilities : these are the default abilities of the users.
	DefaultUserAbilities = []string{}
)

Functions

func AddDefaultUserAbilities

func AddDefaultUserAbilities(abilities []string)

AddDefaultUserAbilities : add some abilities to the default user abilities list.

func AddUserAbilities

func AddUserAbilities(abilities []string)

AddUserAbilities : add some abilities to the user abilities list.

func DeleteAuthTokenByID

func DeleteAuthTokenByID(tokenID string, db *mgo.Database) error

DeleteAuthTokenByID : deletes the document with the ID.

func DeleteAuthTokensByUser

func DeleteAuthTokensByUser(userID string, db *mgo.Database) (int, error)

DeleteAuthTokensByUser : deletes the documents from the user.

func DeleteDeleteAccountProcessByUserID

func DeleteDeleteAccountProcessByUserID(userID string, db *mgo.Database) error

DeleteDeleteAccountProcessByUserID : deletes a process linked to a user.

func DeleteDeletedUserByUserID

func DeleteDeletedUserByUserID(userID string, db *mgo.Database) error

DeleteDeletedUserByUserID : deletes the document with the ID.

func DeleteDisableAccountProcessByUserID

func DeleteDisableAccountProcessByUserID(userID string, db *mgo.Database) error

DeleteDisableAccountProcessByUserID : deletes a process linked to a user.

func DeleteDisabledUserByUserID

func DeleteDisabledUserByUserID(userID string, db *mgo.Database) error

DeleteDisabledUserByUserID : deletes the document with the ID.

func DeleteExpiredAuthTokens

func DeleteExpiredAuthTokens(db *mgo.Database) (int, error)

DeleteExpiredAuthTokens : deletes the expired auth tokens.

func DeleteForgotPasswordProcessByUserID

func DeleteForgotPasswordProcessByUserID(userID string, db *mgo.Database) error

DeleteForgotPasswordProcessByUserID : deletes all the documents linked to a user.

func DeleteUpdateEmailAddressProcessByUserID

func DeleteUpdateEmailAddressProcessByUserID(userID string, db *mgo.Database) error

DeleteUpdateEmailAddressProcessByUserID : deletes a process linked to a user.

func DeleteUpdatePasswordProcessByUserID

func DeleteUpdatePasswordProcessByUserID(userID string, db *mgo.Database) error

DeleteUpdatePasswordProcessByUserID : deletes a process linked to a user.

func DeleteUpdatePropertyProcessByUserIDAndType

func DeleteUpdatePropertyProcessByUserIDAndType(userID, t string, db *mgo.Database) error

DeleteUpdatePropertyProcessByUserIDAndType : deletes a process linked to a user.

func DeleteUpdateValidEmailAddressProcessByUserID

func DeleteUpdateValidEmailAddressProcessByUserID(userID string, db *mgo.Database) error

DeleteUpdateValidEmailAddressProcessByUserID : deletes a process linked to a user.

func DeleteUserByUserID

func DeleteUserByUserID(userID string, db *mgo.Database) error

DeleteUserByUserID : deletes the document with the ID.

func DeleteUserNotifications

func DeleteUserNotifications(notificationsIDs []bson.ObjectId, db *mgo.Database) (int, error)

DeleteUserNotifications : deletes some notifications received by a user.

func GetAnonymousUserID

func GetAnonymousUserID(db *mgo.Database) (string, error)

GetAnonymousUserID : returns the ID of the anonymous user.

func GetCountOfUserNotifications

func GetCountOfUserNotifications(userID string, db *mgo.Database) (int, error)

GetCountOfUserNotifications : returns the count of notifications received by a user.

func GetCountOfUserUnreadNotifications

func GetCountOfUserUnreadNotifications(userID string, db *mgo.Database) (int, error)

GetCountOfUserUnreadNotifications : returns the count of unread notifications received by a user.

func GetInactiveUserIDs

func GetInactiveUserIDs(interval time.Duration, db *mgo.Database) ([]string, error)

GetInactiveUserIDs : returns the ID of the inactive users.

func GetNeverUsedUserIDs

func GetNeverUsedUserIDs(interval time.Duration, db *mgo.Database) ([]string, error)

GetNeverUsedUserIDs : deletes the never used accounts from interval.

func GetOldestUserNotifications

func GetOldestUserNotifications(userID string, offset int, db *mgo.Database) ([]bson.ObjectId, error)

GetOldestUserNotifications : returns the IDs of the oldest notifications received by a user.

func IsDisabledUserWithEmailAddressExisting

func IsDisabledUserWithEmailAddressExisting(emailAddress string, db *mgo.Database) bool

IsDisabledUserWithEmailAddressExisting : returns true if a disabled user with this email address is already existing.

func IsDisabledUserWithFacebookUserIDExisting

func IsDisabledUserWithFacebookUserIDExisting(userID string, db *mgo.Database) bool

IsDisabledUserWithFacebookUserIDExisting : returns true if a disabled user with this facebook user id is already existing.

func IsDisabledUserWithGoogleUserIDExisting

func IsDisabledUserWithGoogleUserIDExisting(userID string, db *mgo.Database) bool

IsDisabledUserWithGoogleUserIDExisting : returns true if a disabled user with this google user id is already existing.

func IsDisabledUserWithUsernameExisting

func IsDisabledUserWithUsernameExisting(username string, db *mgo.Database) bool

IsDisabledUserWithUsernameExisting : returns true if a disabled user with this username is already existing.

func IsDisabledUserWithValidEmailAddressExisting

func IsDisabledUserWithValidEmailAddressExisting(emailAddress string, db *mgo.Database) bool

IsDisabledUserWithValidEmailAddressExisting : returns true if a disabled user with this email address is already existing.

func IsUserWithEmailAddressExisting

func IsUserWithEmailAddressExisting(emailAddress string, db *mgo.Database) bool

IsUserWithEmailAddressExisting : returns true if a user with this email address is already existing.

func IsUserWithFacebookUserIDExisting

func IsUserWithFacebookUserIDExisting(userID string, db *mgo.Database) bool

IsUserWithFacebookUserIDExisting : returns true if a user with this facebook user id is already existing.

func IsUserWithGoogleUserIDExisting

func IsUserWithGoogleUserIDExisting(userID string, db *mgo.Database) bool

IsUserWithGoogleUserIDExisting : returns true if a user with this google user id is already existing.

func IsUserWithUsernameExisting

func IsUserWithUsernameExisting(username string, db *mgo.Database) bool

IsUserWithUsernameExisting : returns true if a user with this username is already existing.

func IsUserWithValidEmailAddressExisting

func IsUserWithValidEmailAddressExisting(emailAddress string, db *mgo.Database) bool

IsUserWithValidEmailAddressExisting : returns true if a user with this email address is already existing.

func IsValidAuthToken

func IsValidAuthToken(tokenID string, db *mgo.Database) bool

IsValidAuthToken : checks that the auth token is valid (non-expired and non-revoked).

Types

type AdminAuthToken

type AdminAuthToken struct {
	ID        bson.ObjectId    `json:"id"`
	Source    string           `json:"source"`
	Method    string           `json:"method"`
	Device    AdminDevice      `json:"device"`
	Location  *AdminIPLocation `json:"location,omitempty"`
	CreatedAt time.Time        `json:"created_at"`
	ExpiresAt time.Time        `json:"expires_at"`
}

AdminAuthToken : admin version of the AuthToken struct

func NewAdminAuthToken

func NewAdminAuthToken(token *AuthToken) *AdminAuthToken

NewAdminAuthToken : returns a new 'AdminAuthToken' struct.

func (*AdminAuthToken) HasLocation

func (token *AdminAuthToken) HasLocation() bool

HasLocation : returns true if the token has a defined location.

func (*AdminAuthToken) URLParams

func (token *AdminAuthToken) URLParams() map[string]string

URLParams : returns a struct containing the parameters to use into a url.

type AdminContact

type AdminContact Contact

AdminContact : admin version of the Contact struct

func NewAdminContact

func NewAdminContact(contact *Contact) *AdminContact

NewAdminContact : returns a new 'AdminContact' struct.

func (AdminContact) URLParams

func (contact AdminContact) URLParams() map[string]string

URLParams : returns a struct containing the parameters to use into a url.

type AdminDevice

type AdminDevice struct {
	Name    string `json:"name" bson:"name"`
	Details string `json:"details" bson:"details"`
	Type    string `json:"type" bson:"type"`
}

AdminDevice : struct

func NewAdminDevice

func NewAdminDevice(device Device) AdminDevice

NewAdminDevice : returns a new 'AdminDevice' struct.

type AdminDisabledUser

type AdminDisabledUser struct {
	ID           bson.ObjectId    `json:"id" bson:"_id,omitempty"`
	Username     string           `json:"username" bson:"username"`
	Slug         string           `json:"slug" bson:"slug"`
	PrivateInfos UserPrivateInfos `json:"private_infos" bson:"privateInfos,omitempty"`
	Verified     bool             `json:"verified" bson:"verified"`
}

AdminDisabledUser : properties of a disabled user for the admin.

func GetDisabledUsersForAdmin

func GetDisabledUsersForAdmin(db *mgo.Database) ([]AdminDisabledUser, error)

GetDisabledUsersForAdmin : returns the disabled users for the admin.

func NewAdminDisabledUser

func NewAdminDisabledUser(user *User) *AdminDisabledUser

NewAdminDisabledUser : returns a new 'AdminDisabledUser' struct.

func (AdminDisabledUser) URLParams

func (user AdminDisabledUser) URLParams() map[string]string

URLParams : returns a struct containing the parameters to use into a url.

type AdminIPLocation

type AdminIPLocation struct {
	IP      string            `json:"IP"`
	Region  string            `json:"region"`
	City    string            `json:"city"`
	Country IPLocationCountry `json:"country"`
}

AdminIPLocation : admin version of the IPLocation struct

func NewAdminIPLocation

func NewAdminIPLocation(location IPLocation) *AdminIPLocation

NewAdminIPLocation : returns a new 'AdminIPLocation' struct.

func (*AdminIPLocation) IsEmpty

func (location *AdminIPLocation) IsEmpty() bool

IsEmpty : returns true if this location is empty.

type AdminSummarizedContact

type AdminSummarizedContact struct {
	ID           bson.ObjectId `json:"id,omitempty" bson:"_id,omitempty"`
	EmailAddress string        `json:"email_address" bson:"emailAddress"`
	Subject      string        `json:"subject" bson:"subject"`
	Done         bool          `json:"done" bson:"done"`
	CreatedAt    time.Time     `json:"created_at" bson:"createdAt"`
}

AdminSummarizedContact : short version of a contact document.

func GetContactsForAdmin

func GetContactsForAdmin(offset, limit int, db *mgo.Database) ([]AdminSummarizedContact, error)

GetContactsForAdmin : returns all the contacts.

func NewAdminSummarizedContact

func NewAdminSummarizedContact(contact *Contact) AdminSummarizedContact

NewAdminSummarizedContact : returns a new 'AdminSummarizedContact' struct.

func (AdminSummarizedContact) URLParams

func (contact AdminSummarizedContact) URLParams() map[string]string

URLParams : returns a struct containing the parameters to use into a url.

type AdminUser

type AdminUser struct {
	ID           bson.ObjectId         `json:"id" bson:"_id,omitempty"`
	Username     string                `json:"username" bson:"username"`
	PrivateInfos AdminUserPrivateInfos `json:"private_infos" bson:"privateInfos,omitempty"`
	Verified     bool                  `json:"verified" bson:"verified"`
}

AdminUser : admin version of the User struct

func GetEnabledUsersForAdmin

func GetEnabledUsersForAdmin(db *mgo.Database) ([]AdminUser, error)

GetEnabledUsersForAdmin : returns the enabled users for the admin.

func NewAdminUser

func NewAdminUser(user *User) *AdminUser

NewAdminUser : returns a new 'AdminUser' struct.

type AdminUserPrivateInfos

type AdminUserPrivateInfos struct {
	Email        string `json:"email" bson:"email"`
	IsEmailValid bool   `json:"is_email_valid" bson:"isEmailValid"`
}

AdminUserPrivateInfos : admin version of the UserPrivateInfos struct

type AuthToken

type AuthToken struct {
	ID        bson.ObjectId `json:"id" bson:"_id,omitempty"`
	UserID    bson.ObjectId `json:"-" bson:"userId,omitempty"`
	Source    string        `json:"source" bson:"source"`
	Method    string        `json:"method" bson:"method"`
	Device    Device        `json:"device" bson:"device"`
	Location  *IPLocation   `json:"location,omitempty" bson:"location,omitempty"`
	Key       string        `json:"key" bson:"key"`
	CreatedAt time.Time     `json:"created_at" bson:"createdAt"`
	ExpiresAt time.Time     `json:"expires_at" bson:"expiresAt"`
}

AuthToken : authentication token properties.

func GetAuthTokens

func GetAuthTokens(userID string, db *mgo.Database) ([]AuthToken, error)

GetAuthTokens : returns all the auth tokens of a user.

func NewAuthToken

func NewAuthToken() *AuthToken

NewAuthToken : returns a new 'AuthToken' struct.

func (*AuthToken) Delete

func (token *AuthToken) Delete(db *mgo.Database) error

Delete : deletes the 'AuthToken' document from the collection, returns an error if needed.

func (*AuthToken) FromToken

func (token *AuthToken) FromToken(t authentication.Token)

FromToken : fills this struct from an 'authentication.Token'.

func (*AuthToken) GetByID

func (token *AuthToken) GetByID(id string, db *mgo.Database) error

GetByID : initializes the 'AuthToken' struct from the 'AuthToken' document with the ID.

func (*AuthToken) GetID

func (token *AuthToken) GetID() string

GetID : returns the 'AuthToken' ID.

func (*AuthToken) IsSaved

func (token *AuthToken) IsSaved() bool

IsSaved : returns true if the 'AuthToken' document if saved in the collection.

func (*AuthToken) Save

func (token *AuthToken) Save(db *mgo.Database) (string, error)

Save : inserts the 'AuthToken' document in the collection, returns an error if needed.

func (*AuthToken) SetID

func (token *AuthToken) SetID(id string)

SetID : initializes the 'AuthToken' ID.

func (*AuthToken) ToToken

func (token *AuthToken) ToToken() authentication.Token

ToToken : returns an 'authentication.Token' struct from this struct.

func (*AuthToken) Update

func (token *AuthToken) Update(update interface{}, db *mgo.Database) error

Update : updates the 'AuthToken' document, returns an error if needed.

func (*AuthToken) UpdateExpirationDate

func (token *AuthToken) UpdateExpirationDate(expirationDate time.Time, db *mgo.Database) error

UpdateExpirationDate : updates the expiration date of the token.

func (*AuthToken) UpdateLocation

func (token *AuthToken) UpdateLocation(location IPLocation, db *mgo.Database) error

UpdateLocation : updates some properties of the token.

func (*AuthToken) UpdateProperties

func (token *AuthToken) UpdateProperties(deviceName string, notificationsEnabled bool, notifications []string, db *mgo.Database) error

UpdateProperties : updates some properties of the token.

type Contact

type Contact struct {
	ID           bson.ObjectId `json:"id,omitempty" bson:"_id,omitempty"`
	EmailAddress string        `json:"email_address" bson:"emailAddress"`
	Subject      string        `json:"subject" bson:"subject"`
	Text         string        `json:"text" bson:"text"`
	Done         bool          `json:"done" bson:"done"`
	CreatedAt    time.Time     `json:"created_at" bson:"createdAt"`
}

Contact : contact properties.

func NewContact

func NewContact() *Contact

NewContact : returns a new 'Contact' struct.

func (*Contact) Delete

func (contact *Contact) Delete(db *mgo.Database) error

Delete : deletes the 'Contact' document from the collection, returns an error if needed.

func (*Contact) GetByID

func (contact *Contact) GetByID(id string, db *mgo.Database) error

GetByID : initializes the 'Contact' struct from the 'Contact' document with the ID.

func (*Contact) GetID

func (contact *Contact) GetID() string

GetID : returns the 'Contact' ID.

func (*Contact) IsSaved

func (contact *Contact) IsSaved() bool

IsSaved : returns true if the 'Contact' document if saved in the collection.

func (*Contact) Save

func (contact *Contact) Save(db *mgo.Database) (string, error)

Save : inserts the 'Contact' document in the collection, returns an error if needed.

func (*Contact) SetID

func (contact *Contact) SetID(id string)

SetID : initializes the 'Contact' ID.

func (*Contact) Update

func (contact *Contact) Update(update interface{}, db *mgo.Database) error

Update : updates the 'Contact' document, returns an error if needed.

func (*Contact) UpdateDone

func (contact *Contact) UpdateDone(done bool, db *mgo.Database) error

UpdateDone : updates the 'done' properties of a contact.

type DeletedUser

type DeletedUser struct {
	ID        bson.ObjectId `json:"id" bson:"_id,omitempty"`
	UserID    bson.ObjectId `json:"-" bson:"userId,omitempty"`
	CreatedAt time.Time     `json:"created_at" bson:"createdAt"`
}

DeletedUser : deleted user properties.

func NewDeletedUser

func NewDeletedUser(userID string) *DeletedUser

NewDeletedUser : returns a new 'DeletedUser' struct.

func (*DeletedUser) Delete

func (deletedUser *DeletedUser) Delete(db *mgo.Database) error

Delete : deletes the 'DeletedUser' document from the collection, returns an error if needed.

func (*DeletedUser) GetByID

func (deletedUser *DeletedUser) GetByID(id string, db *mgo.Database) error

GetByID : initializes the 'DeletedUser' struct from the 'DeletedUser' document with the ID.

func (*DeletedUser) GetID

func (deletedUser *DeletedUser) GetID() string

GetID : returns the 'DeletedUser' ID.

func (*DeletedUser) IsSaved

func (deletedUser *DeletedUser) IsSaved() bool

IsSaved : returns true if the 'DeletedUser' document if saved in the collection.

func (*DeletedUser) Save

func (deletedUser *DeletedUser) Save(db *mgo.Database) (string, error)

Save : inserts the 'DeletedUser' document in the collection, returns an error if needed.

func (*DeletedUser) SetID

func (deletedUser *DeletedUser) SetID(id string)

SetID : initializes the 'DeletedUser' ID.

func (*DeletedUser) Update

func (deletedUser *DeletedUser) Update(update interface{}, db *mgo.Database) error

Update : updates the 'DeletedUser' document, returns an error if needed.

type Device

type Device struct {
	Name                 string             `json:"name" bson:"name"`
	Details              string             `json:"details" bson:"details"`
	Type                 string             `json:"type" bson:"type"`
	UDID                 string             `json:"udid,omitempty" bson:"udid,omitempty"`
	RawName              string             `json:"raw_name" bson:"rawName"`
	NotificationSettings DeviceNotification `json:"notification_settings" bson:"notificationSettings"`
}

Device : struct of a device.

func (*Device) FromDevice

func (device *Device) FromDevice(d authentication.Device)

FromDevice : fills this struct from a struct authentication.Device.

func (*Device) ToDevice

func (device *Device) ToDevice() *authentication.Device

ToDevice : returns a struct authentication.Device from this device struct.

type DeviceNotification

type DeviceNotification struct {
	Token         string   `json:"token,omitempty" bson:"token,omitempty"`
	Enabled       bool     `json:"enabled" bson:"enabled"`
	Notifications []string `json:"notifications" bson:"notifications"`
}

DeviceNotification : settings of the notifications on a device.

type DisabledUser

type DisabledUser struct {
	ID                     bson.ObjectId             `json:"id" bson:"_id,omitempty"`
	UserID                 bson.ObjectId             `json:"user_id" bson:"userId"`
	Username               string                    `json:"username" bson:"username"`
	Slug                   string                    `json:"slug" bson:"slug"`
	Abilities              []string                  `json:"abilities,omitempty" bson:"abilities,omitempty"`
	Notifications          []string                  `json:"notifications" bson:"notifications"`
	NotificationsStats     UserNotificationsStats    `json:"notifications_stats" bson:"notificationsStats"`
	IdentificationMethods  UserIdentificationMethods `json:"identification_methods,omitempty" bson:"identificationMethods,omitempty"`
	PublicInfos            UserPublicInfos           `json:"public_infos" bson:"publicInfos,omitempty"`
	PrivateInfos           UserPrivateInfos          `json:"private_infos" bson:"privateInfos,omitempty"`
	RegistrationInfos      UserRegistrationInfos     `json:"registration_infos,omitempty" bson:"registrationInfos,omitempty"`
	Settings               UserSettings              `json:"settings" bson:"settings"`
	IsAdmin                bool                      `json:"is_admin" bson:"isAdmin"`
	IsAnonymous            bool                      `json:"is_anonymous" bson:"isAnonymous"`
	Verified               bool                      `json:"verified" bson:"verified"`
	VersionOfTermsAccepted string                    `json:"version_of_terms_accepted" bson:"versionOfTermsAccepted"`
	PrivateKey             string                    `json:"-" bson:"privateKey"`
	DisabledAt             time.Time                 `json:"disabled_at" bson:"disabledAt"`
}

DisabledUser : properties of a disabled user.

func NewDisabledUser

func NewDisabledUser(user *User) *DisabledUser

NewDisabledUser : returns a new 'DisabledUser' struct.

func (*DisabledUser) Delete

func (user *DisabledUser) Delete(db *mgo.Database) error

Delete : deletes the 'DisabledUser' document from the collection, returns an error if needed.

func (*DisabledUser) GetByID

func (user *DisabledUser) GetByID(id string, db *mgo.Database) error

GetByID : initializes the 'DisabledUser' struct from the 'DisabledUser' document with the ID.

func (*DisabledUser) GetID

func (user *DisabledUser) GetID() string

GetID : returns the 'DisabledUser' ID.

func (*DisabledUser) IsSaved

func (user *DisabledUser) IsSaved() bool

IsSaved : returns true if the 'DisabledUser' document if saved in the collection.

func (*DisabledUser) Save

func (user *DisabledUser) Save(db *mgo.Database) (string, error)

Save : inserts the 'DisabledUser' document in the collection, returns an error if needed.

func (*DisabledUser) SetID

func (user *DisabledUser) SetID(id string)

SetID : initializes the 'DisabledUser' ID.

func (*DisabledUser) Update

func (user *DisabledUser) Update(update interface{}, db *mgo.Database) error

Update : updates the 'DisabledUser' document, returns an error if needed.

type ForgotPasswordProcess

type ForgotPasswordProcess struct {
	ID     bson.ObjectId `json:"id" bson:"_id,omitempty"`
	UserID bson.ObjectId `json:"user_id" bson:"userId"`
	Code   string        `json:"code" bson:"code"`
	Tries  uint          `json:"-" bson:"tries"`
}

ForgotPasswordProcess : details about the password to update.

func NewForgotPasswordProcess

func NewForgotPasswordProcess(userID string) *ForgotPasswordProcess

NewForgotPasswordProcess : returns a new 'ForgotPasswordProcess' struct.

func (*ForgotPasswordProcess) Delete

func (fpp *ForgotPasswordProcess) Delete(db *mgo.Database) error

Delete : deletes the 'ForgotPasswordProcess' document from the collection, returns an error if needed.

func (*ForgotPasswordProcess) GetByID

func (fpp *ForgotPasswordProcess) GetByID(id string, db *mgo.Database) error

GetByID : initializes the 'ForgotPasswordProcess' struct from the 'user' document with the ID.

func (*ForgotPasswordProcess) GetByUserID

func (fpp *ForgotPasswordProcess) GetByUserID(userID string, db *mgo.Database) error

GetByUserID : returns a ForgotPasswordProcess struct with a user.

func (*ForgotPasswordProcess) GetID

func (fpp *ForgotPasswordProcess) GetID() string

GetID : returns the 'ForgotPasswordProcess' ID.

func (*ForgotPasswordProcess) Increment

func (fpp *ForgotPasswordProcess) Increment(db *mgo.Database) error

Increment : increments the tries of a forgot password proccess document.

func (*ForgotPasswordProcess) IsSaved

func (fpp *ForgotPasswordProcess) IsSaved() bool

IsSaved : returns true if the 'ForgotPasswordProcess' document if saved in the collection.

func (*ForgotPasswordProcess) Save

func (fpp *ForgotPasswordProcess) Save(db *mgo.Database) (string, error)

Save : inserts the 'ForgotPasswordProcess' document in the collection, returns an error if needed.

func (*ForgotPasswordProcess) SetID

func (fpp *ForgotPasswordProcess) SetID(id string)

SetID : initializes the 'ForgotPasswordProcess' ID.

func (*ForgotPasswordProcess) Update

func (fpp *ForgotPasswordProcess) Update(update interface{}, db *mgo.Database) error

Update : updates the 'ForgotPasswordProcess' document, returns an error if needed.

type IPLocation

type IPLocation struct {
	ID      bson.ObjectId     `json:"id,omitempty" bson:"_id,omitempty"`
	IP      string            `json:"IP" bson:"IP"`
	Region  string            `json:"region" bson:"region"`
	City    string            `json:"city" bson:"city"`
	Country IPLocationCountry `json:"country" bson:"country"`
}

IPLocation : IP location properties.

func NewIPLocation

func NewIPLocation() *IPLocation

NewIPLocation : returns a new 'IPLocation' struct.

func (*IPLocation) Delete

func (IPLocation *IPLocation) Delete(db *mgo.Database) error

Delete : deletes the 'IPLocation' document from the collection, returns an error if needed.

func (*IPLocation) GetByID

func (IPLocation *IPLocation) GetByID(id string, db *mgo.Database) error

GetByID : initializes the 'IPLocation' struct from the 'IPLocation' document with the ID.

func (*IPLocation) GetByIPAddress

func (location *IPLocation) GetByIPAddress(IPAddress string, db *mgo.Database) error

GetByIPAddress : initializes the 'IPLocation' struct from the 'IPLocation' document with the IP Address.

func (*IPLocation) GetID

func (IPLocation *IPLocation) GetID() string

GetID : returns the 'IPLocation' ID.

func (*IPLocation) IsEmpty

func (location *IPLocation) IsEmpty() bool

IsEmpty : returns true if this location is empty.

func (*IPLocation) IsSaved

func (IPLocation *IPLocation) IsSaved() bool

IsSaved : returns true if the 'IPLocation' document if saved in the collection.

func (*IPLocation) Save

func (IPLocation *IPLocation) Save(db *mgo.Database) (string, error)

Save : inserts the 'IPLocation' document in the collection, returns an error if needed.

func (*IPLocation) SetID

func (IPLocation *IPLocation) SetID(id string)

SetID : initializes the 'IPLocation' ID.

func (*IPLocation) Update

func (IPLocation *IPLocation) Update(update interface{}, db *mgo.Database) error

Update : updates the 'IPLocation' document, returns an error if needed.

type IPLocationCountry

type IPLocationCountry struct {
	Code string `json:"code" bson:"code"`
	Name string `json:"name" bson:"name"`
}

IPLocationCountry : IP location country properties.

type Image

type Image struct {
	Full  ImageSize `json:"full" bson:"full"`
	Small ImageSize `json:"small" bson:"small"`
	Thumb ImageSize `json:"thumbnail" bson:"thumb"`
}

Image : struct of a image.

type ImageSize

type ImageSize struct {
	Size1x ImageStorage `json:"size1x" bson:"size1x"`
	Size2x ImageStorage `json:"size2x" bson:"size2x"`
}

ImageSize : struct of the size of an image.

type ImageStorage

type ImageStorage struct {
	Path string `json:"path" bson:"path"`
	URL  string `json:"url" bson:"url"`
}

ImageStorage : struct of the size of an image storage.

type Notification

type Notification struct {
	ID        bson.ObjectId                 `json:"id,omitempty" bson:"_id,omitempty"`
	UserID    bson.ObjectId                 `json:"user_id" bson:"userId"`
	Type      string                        `json:"type" bson:"type"`
	Data      string                        `json:"data" bson:"data"`
	Image     PublicImage                   `json:"image,omitempty" bson:"image,omitempty"`
	Locales   map[string]NotificationLocale `json:"locales" bson:"locales"`
	Read      bool                          `json:"read" bson:"read"`
	Notified  bool                          `json:"notified" bson:"notified"`
	CreatedAt time.Time                     `json:"created_at" bson:"createdAt"`
}

Notification : notification properties.

func GetUserNotifications

func GetUserNotifications(userID string, db *mgo.Database) ([]Notification, error)

GetUserNotifications : returns the latest notifications received by a user.

func NewNotification

func NewNotification() *Notification

NewNotification : returns a new 'Notification' struct.

func (*Notification) Delete

func (notification *Notification) Delete(db *mgo.Database) error

Delete : deletes the 'Notification' document from the collection, returns an error if needed.

func (*Notification) GetByID

func (notification *Notification) GetByID(id string, db *mgo.Database) error

GetByID : initializes the 'Notification' struct from the 'Notification' document with the ID.

func (*Notification) GetID

func (notification *Notification) GetID() string

GetID : returns the 'Notification' ID.

func (*Notification) IsSaved

func (notification *Notification) IsSaved() bool

IsSaved : returns true if the 'Notification' document if saved in the collection.

func (*Notification) Save

func (notification *Notification) Save(db *mgo.Database) (string, error)

Save : inserts the 'Notification' document in the collection, returns an error if needed.

func (*Notification) SetID

func (notification *Notification) SetID(id string)

SetID : initializes the 'Notification' ID.

func (*Notification) Update

func (notification *Notification) Update(update interface{}, db *mgo.Database) error

Update : updates the 'Notification' document, returns an error if needed.

func (*Notification) UpdateNotified

func (notification *Notification) UpdateNotified(db *mgo.Database) error

UpdateNotified : updated the notified property of a notification received by a user.

func (*Notification) UpdateRead

func (notification *Notification) UpdateRead(db *mgo.Database) error

UpdateRead : updated the read property of a notification received by a user.

type NotificationLocale

type NotificationLocale struct {
	Title   string `json:"title" bson:"title"`
	Text    string `json:"text" bson:"text"`       // long description
	Preview string `json:"preview" bson:"preview"` // short description
}

NotificationLocale : struct of a locale of a notification.

type OwnAuthToken

type OwnAuthToken struct {
	ID        bson.ObjectId  `json:"id"`
	Source    string         `json:"source"`
	Method    string         `json:"method"`
	Device    OwnDevice      `json:"device"`
	Location  *OwnIPLocation `json:"location,omitempty"`
	CreatedAt time.Time      `json:"created_at"`
	ExpiresAt time.Time      `json:"expires_at"`
}

OwnAuthToken : public version of the AuthToken struct

func NewOwnAuthToken

func NewOwnAuthToken(token *AuthToken) *OwnAuthToken

NewOwnAuthToken : returns a new 'OwnAuthToken' struct.

func (*OwnAuthToken) HasLocation

func (token *OwnAuthToken) HasLocation() bool

HasLocation : returns true if the token has a defined location.

func (*OwnAuthToken) URLParams

func (token *OwnAuthToken) URLParams() map[string]string

URLParams : returns a struct containing the parameters to use into a url.

type OwnDevice

type OwnDevice struct {
	Name                 string                `json:"name" bson:"name"`
	Details              string                `json:"details" bson:"details"`
	Type                 string                `json:"type" bson:"type"`
	NotificationSettings OwnDeviceNotification `json:"notification_settings" bson:"notificationSettings"`
}

OwnDevice : struct

func NewOwnDevice

func NewOwnDevice(device Device) OwnDevice

NewOwnDevice : returns a new 'OwnDevice' struct.

type OwnDeviceNotification

type OwnDeviceNotification struct {
	Enabled       bool     `json:"enabled" bson:"enabled"`
	Notifications []string `json:"notifications" bson:"notifications"`
}

OwnDeviceNotification : struct

func NewOwnDeviceNotification

func NewOwnDeviceNotification(deviceNotification DeviceNotification) OwnDeviceNotification

NewOwnDeviceNotification : returns a new 'OwnDeviceNotification' struct.

type OwnIPLocation

type OwnIPLocation struct {
	IP      string            `json:"IP"`
	Region  string            `json:"region"`
	City    string            `json:"city"`
	Country IPLocationCountry `json:"country"`
}

OwnIPLocation : public version of the IPLocation struct

func NewOwnIPLocation

func NewOwnIPLocation(location IPLocation) *OwnIPLocation

NewOwnIPLocation : returns a new 'OwnIPLocation' struct.

func (*OwnIPLocation) IsEmpty

func (location *OwnIPLocation) IsEmpty() bool

IsEmpty : returns true if this location is empty.

type OwnImage

type OwnImage struct {
	Full  OwnImageSize `json:"full" bson:"full"`
	Small OwnImageSize `json:"small" bson:"small"`
	Thumb OwnImageSize `json:"thumbnail" bson:"thumb"`
}

OwnImage : struct of an image.

func NewOwnImage

func NewOwnImage(image Image) OwnImage

NewOwnImage : returns a new 'OwnImage' struct.

type OwnImageSize

type OwnImageSize struct {
	Size1x string `json:"size1x" bson:"size1x"`
	Size2x string `json:"size2x" bson:"size2x"`
}

OwnImageSize : struct of the size of an image.

type OwnNotification

type OwnNotification struct {
	ID        bson.ObjectId `json:"id,omitempty"`
	Type      string        `json:"type"`
	Data      string        `json:"data"`
	Image     OwnImageSize  `json:"image,omitempty"`
	Title     string        `json:"title"`
	Text      string        `json:"text"`
	Read      bool          `json:"read"`
	Notified  bool          `json:"notified"`
	CreatedAt time.Time     `json:"created_at"`
}

OwnNotification : own version of the Notification struct

func NewOwnNotification

func NewOwnNotification(notification Notification, locale, defaultLocale string) OwnNotification

NewOwnNotification : returns a new 'OwnNotification' struct.

func (OwnNotification) URLParams

func (notification OwnNotification) URLParams() map[string]string

URLParams : returns a struct containing the parameters to use into a url.

type OwnSummarizedNotification

type OwnSummarizedNotification struct {
	ID       bson.ObjectId `json:"id,omitempty"`
	Type     string        `json:"type"`
	Image    OwnImageSize  `json:"image,omitempty"`
	Title    string        `json:"title"`
	Preview  string        `json:"preview"`
	Read     bool          `json:"read"`
	Notified bool          `json:"notified"`
}

OwnSummarizedNotification : own version of the Notification struct

func NewOwnSummarizedNotification

func NewOwnSummarizedNotification(notification Notification, locale, defaultLocale string) OwnSummarizedNotification

NewOwnSummarizedNotification : returns a new 'OwnSummarizedNotification' struct.

func (OwnSummarizedNotification) URLParams

func (notification OwnSummarizedNotification) URLParams() map[string]string

URLParams : returns a struct containing the parameters to use into a url.

type OwnUser

type OwnUser struct {
	ID                     bson.ObjectId       `json:"id"`
	Username               string              `json:"username"`
	PublicInfos            OwnUserPublicInfos  `json:"public_infos"`
	PrivateInfos           OwnUserPrivateInfos `json:"private_infos"`
	Settings               OwnUserSettings     `json:"settings"`
	Abilities              []string            `json:"abilities"`
	Verified               bool                `json:"verified"`
	VersionOfTermsAccepted string              `json:"version_of_terms_accepted"`
}

OwnUser : public version of the User struct

func NewOwnUser

func NewOwnUser(user *User) *OwnUser

NewOwnUser : returns a new 'OwnUser' struct.

func (*OwnUser) HasAbility

func (user *OwnUser) HasAbility(ability string) bool

HasAbility : returns true if the user has the ability.

type OwnUserPrivateInfos

type OwnUserPrivateInfos struct {
	FirstName    string `json:"first_name"`
	LastName     string `json:"last_name"`
	Email        string `json:"email"`
	IsEmailValid bool   `json:"is_email_valid"`
}

OwnUserPrivateInfos : public version of the UserPrivateInfos struct

type OwnUserPublicInfos

type OwnUserPublicInfos struct {
	Description map[string]string `json:"description,omitempty"`
	Facebook    string            `json:"facebook,omitempty"`
	Twitter     string            `json:"twitter,omitempty"`
	Instagram   string            `json:"instagram,omitempty"`
	Image       OwnImage          `json:"image,omitempty"`
}

OwnUserPublicInfos : public informations of a user.

func (*OwnUserPublicInfos) LocalizedDescription

func (publicInfos *OwnUserPublicInfos) LocalizedDescription(locale string) string

LocalizedDescription : returns the localized description of a user.

type OwnUserSettings

type OwnUserSettings struct {
	Locale   string `json:"locale" bson:"locale"`
	Timezone string `json:"timezone" bson:"timezone"`
}

OwnUserSettings : settings of a user.

type PublicImage

type PublicImage struct {
	Full  PublicImageSize `json:"full" bson:"full"`
	Small PublicImageSize `json:"small" bson:"small"`
	Thumb PublicImageSize `json:"thumbnail" bson:"thumb"`
}

PublicImage : struct of an image.

func NewPublicImage

func NewPublicImage(image Image) PublicImage

NewPublicImage : returns a new 'PublicImage' struct.

type PublicImageSize

type PublicImageSize struct {
	Size1x string `json:"size1x" bson:"size1x"`
	Size2x string `json:"size2x" bson:"size2x"`
}

PublicImageSize : struct of the size of an image.

type PublicSummarizedImage

type PublicSummarizedImage PublicImageSize

PublicSummarizedImage : struct of an image.

func NewPublicSummarizedImage

func NewPublicSummarizedImage(image Image) PublicSummarizedImage

NewPublicSummarizedImage : returns a new 'PublicSummarizedImage' struct.

func NewPublicSummarizedImageFromPublicImage

func NewPublicSummarizedImageFromPublicImage(image PublicImage) PublicSummarizedImage

NewPublicSummarizedImageFromPublicImage : returns a new 'PublicSummarizedImage' struct.

type SitemapUser

type SitemapUser struct {
	ID   bson.ObjectId `json:"id" bson:"_id,omitempty"`
	Slug string        `json:"slug" bson:"slug"`
}

SitemapUser : sitemap version of the User struct

func GetSitemapUsers

func GetSitemapUsers(offset, limit int, db *mgo.Database) ([]SitemapUser, error)

GetSitemapUsers : returns users.

func NewSitemapUser

func NewSitemapUser(user User) SitemapUser

NewSitemapUser : returns a new 'SitemapUser' struct.

type UpdatePropertyProcess

type UpdatePropertyProcess struct {
	ID     bson.ObjectId `json:"id" bson:"_id,omitempty"`
	UserID bson.ObjectId `json:"user_id" bson:"userId"`
	Type   string        `json:"type" bson:"type"`
	Value  string        `json:"value" bson:"value"`
	Code   string        `json:"code" bson:"code"`
	Tries  uint          `json:"-" bson:"tries"`
	TTLKey string        `json:"-" bson:"userIdtype"` // This field is indexed with a TTL. A TTL index must use only one field, so the pair 'userId / type' can not be used.
}

UpdatePropertyProcess : details about a property to update.

func NewDeleteAccountProcess

func NewDeleteAccountProcess(userID string) *UpdatePropertyProcess

NewDeleteAccountProcess : returns a new 'UpdatePropertyProcess' struct.

func NewDisableAccountProcess

func NewDisableAccountProcess(userID string) *UpdatePropertyProcess

NewDisableAccountProcess : returns a new 'UpdatePropertyProcess' struct.

func NewUpdateEmailAddressProcess

func NewUpdateEmailAddressProcess(userID, value string) *UpdatePropertyProcess

NewUpdateEmailAddressProcess : returns a new 'UpdatePropertyProcess' struct.

func NewUpdatePasswordProcess

func NewUpdatePasswordProcess(userID, value string) *UpdatePropertyProcess

NewUpdatePasswordProcess : returns a new 'UpdatePropertyProcess' struct.

func NewUpdatePropertyProcess

func NewUpdatePropertyProcess(userID, t, value string) *UpdatePropertyProcess

NewUpdatePropertyProcess : returns a new 'UpdatePropertyProcess' struct.

func NewUpdateValidEmailAddressProcess

func NewUpdateValidEmailAddressProcess(userID string) *UpdatePropertyProcess

NewUpdateValidEmailAddressProcess : returns a new 'UpdatePropertyProcess' struct.

func (*UpdatePropertyProcess) Delete

func (process *UpdatePropertyProcess) Delete(db *mgo.Database) error

Delete : deletes the 'UpdatePropertyProcess' document from the collection, returns an error if needed.

func (*UpdatePropertyProcess) GetByID

func (process *UpdatePropertyProcess) GetByID(id string, db *mgo.Database) error

GetByID : initializes the 'UpdatePropertyProcess' struct from the 'user' document with the ID.

func (*UpdatePropertyProcess) GetByUserIDAndType

func (process *UpdatePropertyProcess) GetByUserIDAndType(userID, t string, db *mgo.Database) error

GetByUserIDAndType : returns a UpdatePropertyProcess struct with a user.

func (*UpdatePropertyProcess) GetDeleteAccountProcessByUserID

func (process *UpdatePropertyProcess) GetDeleteAccountProcessByUserID(userID string, db *mgo.Database) error

GetDeleteAccountProcessByUserID : returns a UpdatePropertyProcess struct with a user.

func (*UpdatePropertyProcess) GetDisableAccountProcessByUserID

func (process *UpdatePropertyProcess) GetDisableAccountProcessByUserID(userID string, db *mgo.Database) error

GetDisableAccountProcessByUserID : returns a UpdatePropertyProcess struct with a user.

func (*UpdatePropertyProcess) GetID

func (process *UpdatePropertyProcess) GetID() string

GetID : returns the 'UpdatePropertyProcess' ID.

func (*UpdatePropertyProcess) GetUpdateEmailAddressProcessByUserID

func (process *UpdatePropertyProcess) GetUpdateEmailAddressProcessByUserID(userID string, db *mgo.Database) error

GetUpdateEmailAddressProcessByUserID : returns a UpdatePropertyProcess struct with a user.

func (*UpdatePropertyProcess) GetUpdatePasswordProcessByUserID

func (process *UpdatePropertyProcess) GetUpdatePasswordProcessByUserID(userID string, db *mgo.Database) error

GetUpdatePasswordProcessByUserID : returns a UpdatePropertyProcess struct with a user.

func (*UpdatePropertyProcess) GetUpdateValidEmailAddressProcessByUserID

func (process *UpdatePropertyProcess) GetUpdateValidEmailAddressProcessByUserID(userID string, db *mgo.Database) error

GetUpdateValidEmailAddressProcessByUserID : returns a UpdatePropertyProcess struct with a user.

func (*UpdatePropertyProcess) Increment

func (process *UpdatePropertyProcess) Increment(db *mgo.Database) error

Increment : increments the tries of a UpdatePropertyProcess document.

func (*UpdatePropertyProcess) IsSaved

func (process *UpdatePropertyProcess) IsSaved() bool

IsSaved : returns true if the 'UpdatePropertyProcess' document if saved in the collection.

func (*UpdatePropertyProcess) Save

func (process *UpdatePropertyProcess) Save(db *mgo.Database) (string, error)

Save : inserts the 'UpdatePropertyProcess' document in the collection, returns an error if needed.

func (*UpdatePropertyProcess) SetID

func (process *UpdatePropertyProcess) SetID(id string)

SetID : initializes the 'UpdatePropertyProcess' ID.

func (*UpdatePropertyProcess) Update

func (process *UpdatePropertyProcess) Update(update interface{}, db *mgo.Database) error

Update : updates the 'UpdatePropertyProcess' document, returns an error if needed.

type User

type User struct {
	ID                     bson.ObjectId             `json:"id" bson:"_id,omitempty"`
	Username               string                    `json:"username" bson:"username"`
	Slug                   string                    `json:"slug" bson:"slug"`
	Abilities              []string                  `json:"abilities,omitempty" bson:"abilities,omitempty"`
	Notifications          []string                  `json:"notifications" bson:"notifications"`
	NotificationsStats     UserNotificationsStats    `json:"notifications_stats" bson:"notificationsStats"`
	IdentificationMethods  UserIdentificationMethods `json:"identification_methods,omitempty" bson:"identificationMethods,omitempty"`
	PublicInfos            UserPublicInfos           `json:"public_infos" bson:"publicInfos,omitempty"`
	PrivateInfos           UserPrivateInfos          `json:"private_infos" bson:"privateInfos,omitempty"`
	RegistrationInfos      UserRegistrationInfos     `json:"registration_infos,omitempty" bson:"registrationInfos,omitempty"`
	Settings               UserSettings              `json:"settings" bson:"settings"`
	IsAdmin                bool                      `json:"is_admin" bson:"isAdmin"`
	IsAnonymous            bool                      `json:"is_anonymous" bson:"isAnonymous"`
	Verified               bool                      `json:"verified" bson:"verified"`
	LastLogin              time.Time                 `json:"last_login,omitempty" bson:"lastLogin,omitempty"`
	VersionOfTermsAccepted string                    `json:"version_of_terms_accepted" bson:"versionOfTermsAccepted"`
	PrivateKey             string                    `json:"-" bson:"privateKey"`
}

User : properties of a user.

func GetAnonymousUser

func GetAnonymousUser(db *mgo.Database) (*User, error)

GetAnonymousUser : returns the anonymous user.

func GetUsersWithAbility

func GetUsersWithAbility(ability string, db *mgo.Database) ([]User, error)

GetUsersWithAbility : return the users with an ability.

func NewUser

func NewUser() *User

NewUser : returns a new 'User' struct.

func NewUserFromDisabledUser

func NewUserFromDisabledUser(user *DisabledUser) *User

NewUserFromDisabledUser : returns a new 'User' struct.

func UserFromAuthToken

func UserFromAuthToken(token *jwt.Token) User

UserFromAuthToken : returns a user with the values of a auth token.

func UserWithID

func UserWithID(userID string) *User

UserWithID : returns a struct 'user' with a ID.

func (*User) AcceptVersionOfTerms

func (user *User) AcceptVersionOfTerms(version string, db *mgo.Database) error

AcceptVersionOfTerms : updates the version of the terms accepted.

func (*User) AddAbilities

func (user *User) AddAbilities(abilities []string, db *mgo.Database) error

AddAbilities : adds some abilities to a user and saves the changes, returns an error if needed.

func (*User) CancelRegistrationByEmailAddress

func (user *User) CancelRegistrationByEmailAddress(code string, db *mgo.Database) error

CancelRegistrationByEmailAddress : cancel the registration by email address.

func (*User) DecrementCountOfUnreadNotifications

func (user *User) DecrementCountOfUnreadNotifications(db *mgo.Database) error

DecrementCountOfUnreadNotifications : decrements the count of unread notifications received by the user.

func (*User) Delete

func (user *User) Delete(db *mgo.Database) error

Delete : deletes the 'user' document from the collection, returns an error if needed.

func (*User) GenerateUnsubscribeKey

func (user *User) GenerateUnsubscribeKey(notificationType string) string

GenerateUnsubscribeKey : generates an unsubscribe key. This key is using to unsubscribe a notification by email without authorization.

func (*User) GetByEmailAddress

func (user *User) GetByEmailAddress(emailAddress string, db *mgo.Database) error

GetByEmailAddress : initializes the 'User' struct from the 'user' document with the email address.

func (*User) GetByFacebookUserID

func (user *User) GetByFacebookUserID(userID string, db *mgo.Database) error

GetByFacebookUserID : initializes the 'User' struct from the 'user' document with the facebook userId.

func (*User) GetByGoogleUserID

func (user *User) GetByGoogleUserID(userID string, db *mgo.Database) error

GetByGoogleUserID : initializes the 'User' struct from the 'user' document with the google userId.

func (*User) GetByID

func (user *User) GetByID(id string, db *mgo.Database) error

GetByID : initializes the 'User' struct from the 'user' document with the ID.

func (*User) GetByIDAndNotification

func (user *User) GetByIDAndNotification(userID, notificationType string, db *mgo.Database) error

GetByIDAndNotification : initializes the 'User' struct from the 'user' document with the email address and a notification type.

func (*User) GetByIdentifier

func (user *User) GetByIdentifier(identifier string, db *mgo.Database) error

GetByIdentifier : initializes the 'User' struct from the 'user' document with the username or the email address.

func (*User) GetByUsername

func (user *User) GetByUsername(username string, db *mgo.Database) error

GetByUsername : initializes the 'User' struct from the 'user' document with the username.

func (*User) GetID

func (user *User) GetID() string

GetID : returns the 'User' ID.

func (*User) HasAbility

func (user *User) HasAbility(ability string) bool

HasAbility : returns true if the user has the ability.

func (*User) IsSaved

func (user *User) IsSaved() bool

IsSaved : returns true if the 'user' document if saved in the collection.

func (*User) RegisterByEmailAddress

func (user *User) RegisterByEmailAddress(username, encryptedPassword, emailAddress, locale, termsVersion, registrationCode, privateKey, source, ip string, device authentication.Device, db *mgo.Database) error

RegisterByEmailAddress : register a new user with an email address.

func (*User) RegisterByThirdPartyToken

func (user *User) RegisterByThirdPartyToken(username string, tokenInfos validator.TokenInfos, tokenSource, locale, termsVersion, registrationCode, privateKey, source, ip string, device authentication.Device, db *mgo.Database) error

RegisterByThirdPartyToken : register a new user with a third-party identification token.

func (*User) RemoveAbilities

func (user *User) RemoveAbilities(abilities []string, db *mgo.Database) error

RemoveAbilities : removes some abilities from a user and saves the changes, returns an error if needed.

func (*User) Save

func (user *User) Save(db *mgo.Database) (string, error)

Save : inserts the 'user' document in the collection, returns an error if needed.

func (*User) SaveFacebookInfos

func (user *User) SaveFacebookInfos(token, userID, firstName, lastName, email string, createdAt, expiresAt time.Time, db *mgo.Database) error

SaveFacebookInfos : saves the facebook access token to the document.

func (*User) SaveGoogleInfos

func (user *User) SaveGoogleInfos(token, userID, firstName, lastName, email string, createdAt, expiresAt time.Time, db *mgo.Database) error

SaveGoogleInfos : saves the google access token to the document.

func (*User) SetAbilities

func (user *User) SetAbilities(abilities []string, db *mgo.Database) error

SetAbilities : sets some abilities up to a user and saves the changes, returns an error if needed.

func (*User) SetAdmin

func (user *User) SetAdmin(admin bool, db *mgo.Database) error

SetAdmin : !Only for testing

func (*User) SetEmailAddressValid

func (user *User) SetEmailAddressValid(db *mgo.Database) error

SetEmailAddressValid : updates the email address of a user.

func (*User) SetID

func (user *User) SetID(id string)

SetID : initializes the 'User' ID.

func (*User) ToUser

func (user *User) ToUser() authentication.User

ToUser : return a authentication.User struct from this model.User struct.

func (*User) UnsubscribeNotification

func (user *User) UnsubscribeNotification(notificationType string, db *mgo.Database) error

UnsubscribeNotification : unsubscribe from a single notification.

func (*User) Update

func (user *User) Update(update interface{}, db *mgo.Database) error

Update : updates the 'user' document, returns an error if needed.

func (*User) UpdateAllInformations

func (user *User) UpdateAllInformations(firstName, lastName, emailAddress string, validEmailAddress bool, db *mgo.Database) error

UpdateAllInformations : updates the infos of an account.

func (*User) UpdateCountOfNotifications

func (user *User) UpdateCountOfNotifications(total, unread int, db *mgo.Database) error

UpdateCountOfNotifications : updates the count of notifications received by the user.

func (*User) UpdateEmailAddress

func (user *User) UpdateEmailAddress(emailAddress string, db *mgo.Database) error

UpdateEmailAddress : updates the email address of a user.

func (*User) UpdateImage

func (user *User) UpdateImage(db *mgo.Database) error

UpdateImage : updates the image of a user.

func (*User) UpdateInfos

func (user *User) UpdateInfos(firstName, lastName string, db *mgo.Database) error

UpdateInfos : updates the infos of an account.

func (*User) UpdateLastLogin

func (user *User) UpdateLastLogin(db *mgo.Database) error

UpdateLastLogin : updates the last login date.

func (*User) UpdateNotifications

func (user *User) UpdateNotifications(notifications []string, db *mgo.Database) error

UpdateNotifications : updates the notifications received by the user by email.

func (*User) UpdatePassword

func (user *User) UpdatePassword(newPassword string, alreadyEncrypted bool, db *mgo.Database) error

UpdatePassword : updates the password of a user.

func (*User) UpdatePublicProfile

func (user *User) UpdatePublicProfile(locale, description string, db *mgo.Database) error

UpdatePublicProfile : updates the public profile of a user.

func (*User) UpdateSettings

func (user *User) UpdateSettings(locale, timezone string, db *mgo.Database) error

UpdateSettings : updates the settings of an account.

func (*User) UpdateSocialNetworks

func (user *User) UpdateSocialNetworks(facebook, twitter, instagram string, db *mgo.Database) error

UpdateSocialNetworks : updates the social network profiles of a user.

func (*User) ValidateRegistrationByEmailAddress

func (user *User) ValidateRegistrationByEmailAddress(code string, db *mgo.Database) error

ValidateRegistrationByEmailAddress : validate the registration by email address.

type UserIdentificationMethods

type UserIdentificationMethods struct {
	Password string         `json:"-" bson:"password"`
	Facebook UserOAuthInfos `json:"facebook,omitempty" bson:"facebook,omitempty"`
	Google   UserOAuthInfos `json:"google,omitempty" bson:"google,omitempty"`
	Twitter  UserOAuthInfos `json:"twitter,omitempty" bson:"twitter,omitempty"`
}

UserIdentificationMethods : identification methods of a user.

type UserNotificationTarget

type UserNotificationTarget struct {
	Type  string `bson:"type"`
	Value string `bson:"token"`
}

UserNotificationTarget target of a notification to send a user.

func GetUserNotificationTargetsByType

func GetUserNotificationTargetsByType(userID, notificationType string, db *mgo.Database) []UserNotificationTarget

GetUserNotificationTargetsByType : returns the targets of a given notification type of a user.

type UserNotificationsStats

type UserNotificationsStats struct {
	Total  string `json:"total" bson:"total"`
	Unread int    `json:"unread" bson:"unread"`
}

UserNotificationsStats : informations about the notifications received by the user.

type UserOAuthInfos

type UserOAuthInfos struct {
	UserID    string    `json:"user_id" bson:"userId"`
	Token     string    `json:"token" bson:"token"`
	FirstName string    `json:"first_name" bson:"firstName,omitempty"`
	LastName  string    `json:"last_name" bson:"lastName,omitempty"`
	Email     string    `json:"email" bson:"email,omitempty"`
	CreatedAt time.Time `json:"created_at" bson:"createdAt,omitempty"`
	ExpiresAt time.Time `json:"expires_at" bson:"expiresAt,omitempty"`
}

UserOAuthInfos : informations of a user from a oauth service.

func (*UserOAuthInfos) FromSocialNetworkOAuthInfos

func (oauthInfos *UserOAuthInfos) FromSocialNetworkOAuthInfos(tokenInfos validator.TokenInfos)

FromSocialNetworkOAuthInfos : fills a UserOAuthInfos struct from a TokenInfos struct

type UserPrivateInfos

type UserPrivateInfos struct {
	FirstName    string `json:"first_name" bson:"firstName"`
	LastName     string `json:"last_name" bson:"lastName"`
	Email        string `json:"email" bson:"email"`
	IsEmailValid bool   `json:"is_email_valid" bson:"isEmailValid"`
}

UserPrivateInfos : private informations of a user.

type UserPublicInfos

type UserPublicInfos struct {
	Description map[string]string `json:"description,omitempty" bson:"description,omitempty"`
	Facebook    string            `json:"facebook,omitempty" bson:"facebook,omitempty"`
	Twitter     string            `json:"twitter,omitempty" bson:"twitter,omitempty"`
	Instagram   string            `json:"instagram,omitempty" bson:"instagram,omitempty"`
	Image       Image             `json:"image,omitempty" bson:"image,omitempty"`
}

UserPublicInfos : public informations of a user.

type UserRegistrationInfos

type UserRegistrationInfos struct {
	Date         time.Time `json:"date" bson:"date"`
	Source       string    `json:"source" bson:"source"`
	Method       string    `json:"method" bson:"method"`
	Device       Device    `json:"device" bson:"device"`
	IPAddress    string    `json:"ip_address" bson:"ip"`
	Code         string    `json:"-" bson:"code"`
	CodeAttempts uint      `json:"-" bson:"codeAttempts"`
}

UserRegistrationInfos : private informations of a user.

type UserSettings

type UserSettings struct {
	Locale   string `json:"locale" bson:"locale"`
	Timezone string `json:"timezone" bson:"timezone"`
}

UserSettings : settings of a user.

Source Files

Jump to

Keyboard shortcuts

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