Documentation
¶
Index ¶
- Constants
- type Account
- type ContactInfo
- type ContactInfoType
- type ContactPreferences
- type OTP
- type OTPType
- type Profile
- type RenewToken
- type TempToken
- type Timestamps
- type User
- func (u *User) AddNewEmail(addr string, confirmed bool)
- func (u *User) AddProfile(p *Profile)
- func (u *User) ConfirmContactInfo(t ContactInfoType, addr string) error
- func (u *User) ConfirmPhoneNumber() error
- func (u User) FindContactInfoById(id string) (ContactInfo, bool)
- func (u User) FindContactInfoByTypeAndAddr(t ContactInfoType, addr string) (ContactInfo, bool)
- func (u User) FindProfile(id string) (Profile, error)
- func (u *User) GetEmail() (ContactInfo, error)
- func (u *User) GetPhoneNumber() (ContactInfo, error)
- func (u *User) RemoveContactInfo(id string) error
- func (u *User) RemoveContactInfoFromContactPreferences(id string)
- func (u *User) RemoveProfile(id string) error
- func (u *User) ReplaceContactInfoInContactPreferences(oldId string, newId string)
- func (u *User) SetContactInfoVerificationSent(t ContactInfoType, addr string)
- func (u *User) SetPhoneNumber(phone string)
- func (u *User) UpdateProfile(p Profile) error
- type UserAttributes
- type VerificationCode
Constants ¶
View Source
const ( TOKEN_PURPOSE_INVITATION = "invitation" TOKEN_PURPOSE_PASSWORD_RESET = "password-reset" TOKEN_PURPOSE_CONTACT_VERIFICATION = "contact-verification" TOKEN_PURPOSE_SURVEY_LOGIN = "survey-login" TOKEN_PURPOSE_UNSUBSCRIBE_NEWSLETTER = "unsubscribe-newsletter" TOKEN_PURPOSE_RESTORE_ACCOUNT_ID = "restore_account_id" TOKEN_PURPOSE_INACTIVE_USER_NOTIFICATION = "inactive-user-notification" )
View Source
const ACCOUNT_TYPE_EMAIL = "email"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct {
Type string `bson:"type" json:"type"`
AccountID string `bson:"accountID" json:"accountID"`
AccountConfirmedAt int64 `bson:"accountConfirmedAt" json:"accountConfirmedAt"`
Password string `bson:"password" json:"password"`
AuthType string `bson:"authType" json:"authType"`
VerificationCode VerificationCode `bson:"verificationCode" json:"verificationCode"`
PreferredLanguage string `bson:"preferredLanguage" json:"preferredLanguage"`
// Rate limiting
FailedLoginAttempts []int64 `bson:"failedLoginAttempts" json:"failedLoginAttempts"`
PasswordResetTriggers []int64 `bson:"passwordResetTriggers" json:"passwordResetTriggers"`
}
type ContactInfo ¶
type ContactInfo struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
Type ContactInfoType `bson:"type" json:"type"`
ConfirmedAt int64 `bson:"confirmedAt" json:"confirmedAt"`
ConfirmationLinkSentAt int64 `bson:"confirmationLinkSentAt" json:"confirmationLinkSentAt"`
Email string `bson:"email,omitempty" json:"email,omitempty"`
Phone string `bson:"phone,omitempty" json:"phone,omitempty"`
}
type ContactInfoType ¶
type ContactInfoType string
const ( CONTACT_INFO_TYPE_EMAIL ContactInfoType = "email" CONTACT_INFO_TYPE_PHONE ContactInfoType = "phone" )
type ContactPreferences ¶
type ContactPreferences struct {
SubscribedToNewsletter bool `bson:"subscribedToNewsletter" json:"subscribedToNewsletter"`
SendNewsletterTo []string `bson:"sendNewsletterTo" json:"sendNewsletterTo"`
SubscribedToWeekly bool `bson:"subscribedToWeekly" json:"subscribedToWeekly"`
ReceiveWeeklyMessageDayOfWeek int32 `bson:"receiveWeeklyMessageDayOfWeek" json:"receiveWeeklyMessageDayOfWeek"`
}
type Profile ¶
type Profile struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
Alias string `bson:"alias" json:"alias"`
ConsentConfirmedAt int64 `bson:"consentConfirmedAt" json:"consentConfirmedAt"`
CreatedAt int64 `bson:"createdAt" json:"createdAt"`
AvatarID string `bson:"avatarID" json:"avatarID"`
MainProfile bool `bson:"mainProfile" json:"mainProfile"`
}
type RenewToken ¶
type RenewToken struct {
UserID string `bson:"userID,omitempty"`
SessionID string `bson:"sessionID,omitempty"`
RenewToken string `bson:"renewToken,omitempty"`
ExpiresAt time.Time `bson:"expiresAt,omitempty"`
NextToken string `bson:"nextToken,omitempty"` // token that replaces the current renew token
}
type TempToken ¶
type TempToken struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"token_id,omitempty"`
Token string `bson:"token" json:"token"`
Expiration time.Time `bson:"expiration" json:"expiration"`
Purpose string `bson:"purpose" json:"purpose"`
UserID string `bson:"userID" json:"userID"`
Info map[string]string `bson:"info" json:"info"`
InstanceID string `bson:"instanceID" json:"instanceID"`
}
type Timestamps ¶
type Timestamps struct {
LastTokenRefresh int64 `bson:"lastTokenRefresh" json:"lastTokenRefresh"`
LastLogin int64 `bson:"lastLogin" json:"lastLogin"`
CreatedAt int64 `bson:"createdAt" json:"createdAt"`
UpdatedAt int64 `bson:"updatedAt" json:"updatedAt"`
LastPasswordChange int64 `bson:"lastPasswordChange" json:"lastPasswordChange"`
ReminderToConfirmSentAt int64 `bson:"reminderToConfirmSentAt" json:"reminderToConfirmSentAt"`
MarkedForDeletion int64 `bson:"markedForDeletion" json:"markedForDeletion"`
}
type User ¶
type User struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
Account Account `bson:"account" json:"account"`
Timestamps Timestamps `bson:"timestamps" json:"timestamps"`
Profiles []Profile `bson:"profiles" json:"profiles"`
ContactPreferences ContactPreferences `bson:"contactPreferences" json:"contactPreferences"`
ContactInfos []ContactInfo `bson:"contactInfos" json:"contactInfos"`
}
func (*User) AddNewEmail ¶
Add a new email address
func (*User) AddProfile ¶
AddProfile generates unique ID and adds profile to the user's array
func (*User) ConfirmContactInfo ¶
func (u *User) ConfirmContactInfo(t ContactInfoType, addr string) error
func (*User) ConfirmPhoneNumber ¶
func (User) FindContactInfoById ¶
func (u User) FindContactInfoById(id string) (ContactInfo, bool)
func (User) FindContactInfoByTypeAndAddr ¶
func (u User) FindContactInfoByTypeAndAddr(t ContactInfoType, addr string) (ContactInfo, bool)
func (User) FindProfile ¶
FindProfile finds a profile in the user's array
func (*User) GetEmail ¶
func (u *User) GetEmail() (ContactInfo, error)
func (*User) GetPhoneNumber ¶
func (u *User) GetPhoneNumber() (ContactInfo, error)
func (*User) RemoveContactInfo ¶
RemoveContactInfo from the user and also all references from the contact preferences
func (*User) RemoveContactInfoFromContactPreferences ¶
RemoveContactInfoFromContactPreferences should delete all references to a contact info object
func (*User) RemoveProfile ¶
RemoveProfile finds and removes profile from the user's array
func (*User) ReplaceContactInfoInContactPreferences ¶
ReplaceContactInfoInContactPreferences to use if a new contact reference should replace to old one
func (*User) SetContactInfoVerificationSent ¶
func (u *User) SetContactInfoVerificationSent(t ContactInfoType, addr string)
func (*User) SetPhoneNumber ¶
func (*User) UpdateProfile ¶
UpdateProfile finds and replaces profile in the user's array
type UserAttributes ¶
Click to show internal directories.
Click to hide internal directories.