types

package
v0.0.0-...-08cdbde Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

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 OTP

type OTP struct {
	Code      string    `bson:"code" json:"code"`
	UserID    string    `bson:"userID" json:"userID"`
	CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
	Type      OTPType   `bson:"type" json:"type"`
}

type OTPType

type OTPType string
const (
	EmailOTP OTPType = "email"
	SMSOTP   OTPType = "sms"
)

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

func (u *User) AddNewEmail(addr string, confirmed bool)

Add a new email address

func (*User) AddProfile

func (u *User) AddProfile(p *Profile)

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 (u *User) ConfirmPhoneNumber() error

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

func (u User) FindProfile(id string) (Profile, error)

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

func (u *User) RemoveContactInfo(id string) error

RemoveContactInfo from the user and also all references from the contact preferences

func (*User) RemoveContactInfoFromContactPreferences

func (u *User) RemoveContactInfoFromContactPreferences(id string)

RemoveContactInfoFromContactPreferences should delete all references to a contact info object

func (*User) RemoveProfile

func (u *User) RemoveProfile(id string) error

RemoveProfile finds and removes profile from the user's array

func (*User) ReplaceContactInfoInContactPreferences

func (u *User) ReplaceContactInfoInContactPreferences(oldId string, newId string)

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 (u *User) SetPhoneNumber(phone string)

func (*User) UpdateProfile

func (u *User) UpdateProfile(p Profile) error

UpdateProfile finds and replaces profile in the user's array

type UserAttributes

type UserAttributes struct {
	ID         primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	UserID     primitive.ObjectID `bson:"userId" json:"userId"`
	Type       string             `bson:"type" json:"type"`
	Attributes map[string]any     `bson:"attributes" json:"attributes"`
	CreatedAt  time.Time          `bson:"createdAt" json:"createdAt"`
}

type VerificationCode

type VerificationCode struct {
	Code      string `bson:"code" json:"code"`
	Attempts  int64  `bson:"attempts" json:"attempts"`
	CreatedAt int64  `bson:"createdAt" json:"createdAt"`
	ExpiresAt int64  `bson:"expiresAt" json:"expiresAt"`
}

Jump to

Keyboard shortcuts

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