Documentation
¶
Index ¶
- Constants
- type Account
- type AccountData
- type AccountDataBase
- type AccountRecord
- type AccountsOfUser
- func (ua *AccountsOfUser) AddAccount(userAccount Account) (changed bool)
- func (ua *AccountsOfUser) GetAccount(provider, app string) (userAccount *Account, err error)
- func (ua *AccountsOfUser) GetAccounts(platform string) (userAccounts []Account, err error)
- func (ua *AccountsOfUser) GetFbAccount(app string) (userAccount *Account, err error)
- func (ua *AccountsOfUser) GetFbAccounts() (userAccounts []Account, err error)
- func (ua *AccountsOfUser) GetFbmAccount(fbPageID string) (userAccount *Account, err error)
- func (ua *AccountsOfUser) GetGoogleAccount() (userAccount *Account, err error)
- func (ua *AccountsOfUser) GetTelegramAccounts() (telegramAccounts []Account)
- func (ua *AccountsOfUser) GetTelegramUserIDs() (telegramUserIDs []int64)
- func (ua *AccountsOfUser) HasAccount(provider, app string) bool
- func (ua *AccountsOfUser) HasGoogleAccount() bool
- func (ua *AccountsOfUser) HasTelegramAccount() bool
- func (ua *AccountsOfUser) RemoveAccount(userAccount Account) (changed bool)
- func (ua *AccountsOfUser) SetBotUserID(platform, botID, botUserID string)
- type BaseUserData
- type BaseUserFields
- type BelongsToUser
- type CreatedTimeGetter
- type EmailData
- type LastLogin
- type Name
- type NameFields
- type NamesSetter
- type OwnedByUserWithID
- func (ownedByUser *OwnedByUserWithID) GetAppUserID() string
- func (ownedByUser *OwnedByUserWithID) GetAppUserIntID() int64
- func (ownedByUser *OwnedByUserWithID) GetCreatedTime() time.Time
- func (ownedByUser *OwnedByUserWithID) GetUpdatedTime() time.Time
- func (ownedByUser *OwnedByUserWithID) SetAppUserID(appUserID string)
- func (ownedByUser *OwnedByUserWithID) SetAppUserIntID(appUserID int64)
- func (ownedByUser *OwnedByUserWithID) SetCreatedTime(v time.Time)
- func (ownedByUser *OwnedByUserWithID) SetUpdatedTime(v time.Time)
- func (ownedByUser *OwnedByUserWithID) Validate() error
- type WithCreatedTimestamp
- type WithPreferredLocale
Constants ¶
const ( Username name = iota FirstName MiddleName LastName NickName )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct {
// Global ID of Account
Provider string // E.g. Email, Google, Facebook, etc.
App string
ID string // An ID of a user at auth provider. E.g. email address, some ID, etc.
}
Account stores info about user account with auth provider
func ParseUserAccount ¶
type AccountData ¶
type AccountData interface {
BelongsToUser
GetEmailLowerCase() string
GetEmailConfirmed() bool
SetLastLogin(time time.Time)
GetNames() NameFields
}
AccountData stores info about user account with auth provider
type AccountDataBase ¶
type AccountDataBase struct {
Account
OwnedByUserWithID
NameFields
LastLogin
EmailData
Admin bool
// ClientID is an OAuth2 client ID
ClientID string
FederatedIdentity string `dalgo:",noindex" datastore:",noindex"`
FederatedProvider string `dalgo:",noindex" datastore:",noindex"`
}
func (*AccountDataBase) GetNames ¶
func (a *AccountDataBase) GetNames() NameFields
func (*AccountDataBase) SetLastLogin ¶
func (a *AccountDataBase) SetLastLogin(time time.Time)
type AccountRecord ¶
type AccountRecord interface {
Key() Account
Data() AccountData
}
type AccountsOfUser ¶
type AccountsOfUser struct {
// Member of TgUserEntity class
Accounts []string `datastore:",noindex"`
}
func (*AccountsOfUser) AddAccount ¶
func (ua *AccountsOfUser) AddAccount(userAccount Account) (changed bool)
func (*AccountsOfUser) GetAccount ¶
func (ua *AccountsOfUser) GetAccount(provider, app string) (userAccount *Account, err error)
GetAccount returns the first account of the given provider and app.
func (*AccountsOfUser) GetAccounts ¶
func (ua *AccountsOfUser) GetAccounts(platform string) (userAccounts []Account, err error)
func (*AccountsOfUser) GetFbAccount ¶
func (ua *AccountsOfUser) GetFbAccount(app string) (userAccount *Account, err error)
func (*AccountsOfUser) GetFbAccounts ¶
func (ua *AccountsOfUser) GetFbAccounts() (userAccounts []Account, err error)
func (*AccountsOfUser) GetFbmAccount ¶
func (ua *AccountsOfUser) GetFbmAccount(fbPageID string) (userAccount *Account, err error)
func (*AccountsOfUser) GetGoogleAccount ¶
func (ua *AccountsOfUser) GetGoogleAccount() (userAccount *Account, err error)
func (*AccountsOfUser) GetTelegramAccounts ¶
func (ua *AccountsOfUser) GetTelegramAccounts() (telegramAccounts []Account)
func (*AccountsOfUser) GetTelegramUserIDs ¶
func (ua *AccountsOfUser) GetTelegramUserIDs() (telegramUserIDs []int64)
func (*AccountsOfUser) HasAccount ¶
func (ua *AccountsOfUser) HasAccount(provider, app string) bool
func (*AccountsOfUser) HasGoogleAccount ¶
func (ua *AccountsOfUser) HasGoogleAccount() bool
func (*AccountsOfUser) HasTelegramAccount ¶
func (ua *AccountsOfUser) HasTelegramAccount() bool
func (*AccountsOfUser) RemoveAccount ¶
func (ua *AccountsOfUser) RemoveAccount(userAccount Account) (changed bool)
RemoveAccount removes account from the list of account IDs.
func (*AccountsOfUser) SetBotUserID ¶
func (ua *AccountsOfUser) SetBotUserID(platform, botID, botUserID string)
type BaseUserData ¶
type BaseUserData interface {
NamesSetter
SetPreferredLocale(code5 string) error
GetPreferredLocale() string
GetCreatedTime() time.Time
}
BaseUserData defines app user interface
type BaseUserFields ¶
type BaseUserFields struct {
NameFields
AccountsOfUser
WithPreferredLocale
WithCreatedTimestamp
}
BaseUserFields hold common properties for BaseUserData interface
type BelongsToUser ¶
type BelongsToUser interface {
GetAppUserID() (appUserID string)
SetAppUserID(appUserID string)
GetCreatedTime() time.Time
GetUpdatedTime() time.Time
SetUpdatedTime(time.Time)
}
BelongsToUser should be implemented by any struct that belongs to a single user
type CreatedTimeGetter ¶
type EmailData ¶
type EmailData struct {
// Deprecated: use EmailRaw & EmailLowerCase instead
Email string `dalgo:",noindex" datastore:",noindex"` // TODO: remove once old records migrated to new format that uses EmailRaw & EmailLowerCase
EmailRaw string `dalgo:",noindex" datastore:",noindex"`
EmailLowerCase string
EmailConfirmed bool
}
EmailData stores info about email
func NewEmailData ¶
func (*EmailData) GetEmailConfirmed ¶
func (*EmailData) GetEmailLowerCase ¶
func (*EmailData) GetEmailRaw ¶
func (*EmailData) SetEmailConfirmed ¶
type LastLogin ¶
LastLogin is a struct that contains the last login time of a user.
func (*LastLogin) SetLastLogin ¶
SetLastLogin sets the last login time of a user.
type NameFields ¶
type NameFields struct {
FirstName string `json:"firstName,omitempty" dalgo:"firstName,omitempty" firestore:"firstName,omitempty"`
MiddleName string `json:"middleName,omitempty" dalgo:"middleName,omitempty" firestore:"middleName,omitempty"`
LastName string `json:"lastName,omitempty" dalgo:"lastName,omitempty" firestore:"lastName,omitempty"`
NickName string `json:"nickName,omitempty" dalgo:"nickName,omitempty" firestore:"nickName,omitempty"`
UserName string `json:"userName,omitempty" dalgo:"userName,omitempty" firestore:"userName,omitempty"`
}
func (*NameFields) GetFullName ¶
func (u *NameFields) GetFullName() string
func (*NameFields) GetName ¶
func (u *NameFields) GetName(field name) string
func (*NameFields) SetNames ¶
func (u *NameFields) SetNames(names ...Name)
func (*NameFields) String ¶
func (u *NameFields) String() string
type NamesSetter ¶
type NamesSetter interface {
SetNames(names ...Name)
}
type OwnedByUserWithID ¶
type OwnedByUserWithID struct {
AppUserID string // intentionally indexed & do NOT omitempty (so we can find records with empty AppUserID)
// AppUserIntID is a strongly typed integer ID of a user
// Deprecated: use AppUserID instead. Remove BelongsToUserWithIntID once AppUserIntID is removed.
AppUserIntID int64
DtCreated time.Time `json:",omitempty" datastore:",omitempty" firestore:",omitempty"`
DtUpdated time.Time `json:",omitempty" datastore:",omitempty" firestore:",omitempty"`
}
OwnedByUserWithID is a struct that implements BelongsToUser & BelongsToUserWithIntID
func NewOwnedByUserWithID ¶
func NewOwnedByUserWithID(id string, created time.Time) OwnedByUserWithID
NewOwnedByUserWithID creates a new OwnedByUserWithID, takes user ID and time of creation
func (*OwnedByUserWithID) GetAppUserID ¶
func (ownedByUser *OwnedByUserWithID) GetAppUserID() string
func (*OwnedByUserWithID) GetAppUserIntID ¶
func (ownedByUser *OwnedByUserWithID) GetAppUserIntID() int64
func (*OwnedByUserWithID) GetCreatedTime ¶
func (ownedByUser *OwnedByUserWithID) GetCreatedTime() time.Time
func (*OwnedByUserWithID) GetUpdatedTime ¶
func (ownedByUser *OwnedByUserWithID) GetUpdatedTime() time.Time
func (*OwnedByUserWithID) SetAppUserID ¶
func (ownedByUser *OwnedByUserWithID) SetAppUserID(appUserID string)
func (*OwnedByUserWithID) SetAppUserIntID ¶
func (ownedByUser *OwnedByUserWithID) SetAppUserIntID(appUserID int64)
func (*OwnedByUserWithID) SetCreatedTime ¶
func (ownedByUser *OwnedByUserWithID) SetCreatedTime(v time.Time)
func (*OwnedByUserWithID) SetUpdatedTime ¶
func (ownedByUser *OwnedByUserWithID) SetUpdatedTime(v time.Time)
func (*OwnedByUserWithID) Validate ¶
func (ownedByUser *OwnedByUserWithID) Validate() error
type WithCreatedTimestamp ¶
type WithCreatedTimestamp struct {
DtCreated time.Time `json:"dtCreated,omitempty" firestore:"dtCreated,omitempty" dalgo:"dtCreated,omitempty"`
}
func (*WithCreatedTimestamp) GetCreatedTime ¶
func (u *WithCreatedTimestamp) GetCreatedTime() time.Time
type WithPreferredLocale ¶
type WithPreferredLocale struct {
PreferredLocale string `json:"preferredLocale,omitempty" dalgo:"preferredLocale,omitempty" firestore:"preferredLocale,omitempty"`
}
func (*WithPreferredLocale) GetPreferredLocale ¶
func (u *WithPreferredLocale) GetPreferredLocale() string
GetPreferredLocale gets preferred locale
func (*WithPreferredLocale) SetPreferredLocale ¶
func (u *WithPreferredLocale) SetPreferredLocale(v string) error
SetPreferredLocale sets preferred locale