Documentation
¶
Index ¶
- Constants
- type AccountData
- type AccountDataBase
- type AccountKey
- type AccountRecord
- type AccountsOfUser
- func (ua *AccountsOfUser) AddAccount(userAccount AccountKey) (updates []update.Update)
- func (ua *AccountsOfUser) GetAccount(provider, app string) (userAccount *AccountKey, err error)
- func (ua *AccountsOfUser) GetAccounts(platform string) (userAccounts []AccountKey, err error)
- func (ua *AccountsOfUser) GetFbAccount(_ string) (userAccount *AccountKey, err error)deprecated
- func (ua *AccountsOfUser) GetFbAccounts() (userAccounts []AccountKey, err error)deprecated
- func (ua *AccountsOfUser) GetFbmAccount(_ string) (userAccount *AccountKey, err error)deprecated
- func (ua *AccountsOfUser) GetGoogleAccount() (userAccount *AccountKey, err error)deprecated
- func (ua *AccountsOfUser) GetTelegramAccounts() (telegramAccounts []AccountKey, er error)deprecated
- func (ua *AccountsOfUser) GetTelegramUserIDs() (telegramUserIDs []int64)
- func (ua *AccountsOfUser) HasAccount(provider, app string) bool
- func (ua *AccountsOfUser) HasGoogleAccount() booldeprecated
- func (ua *AccountsOfUser) HasTelegramAccount() booldeprecated
- func (ua *AccountsOfUser) RemoveAccount(userAccount AccountKey) (changed bool)
- func (ua *AccountsOfUser) SetBotUserID(platform, botID, botUserID string)
- func (ua *AccountsOfUser) Validate() error
- type BaseUserData
- type BaseUserFields
- type BelongsToUser
- type EmailData
- type OwnedByUserWithID
- type WithLastLogin
Constants ¶
const AccountKeySeparator = ":"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountData ¶
type AccountData interface {
BelongsToUser
GetEmailLowerCase() string
GetEmailConfirmed() bool
SetLastLoginAt(time time.Time) update.Update
GetNames() person.NameFields
}
AccountData stores info about a user account with auth provider
type AccountDataBase ¶
type AccountDataBase struct {
AccountKey
OwnedByUserWithID
person.NameFields
WithLastLogin
EmailData
Domains []string `json:"domains" dalgo:"domains" firestore:"domains"` // E.g. website domain names used to authenticate user
Admin bool
// ClientID is an OAuth2 client ID
ClientID string `json:"clientID" dalgo:"clientID" firestore:"clientID"`
FederatedIdentity string `firestore:"federatedIdentity"`
FederatedProvider string `firestore:"federatedProvider"`
}
func (*AccountDataBase) GetNames ¶
func (v *AccountDataBase) GetNames() person.NameFields
func (*AccountDataBase) Validate ¶ added in v0.21.0
func (v *AccountDataBase) Validate() error
type AccountKey ¶ added in v0.10.0
type AccountKey struct {
// Global ID of AccountKey
Provider string `json:"provider" dalgo:"provider" firestore:"dalgo"` // E.g. Email, Google, Facebook, etc.
App string `json:"app" dalgo:"app" firestore:"app"` // E.g. app ID, bot ID, etc.
ID string `json:"id" dalgo:"id" firestore:"id"` // An ID of a user at auth provider. E.g. email address, some ID, etc.
}
AccountKey stores info about a user account with auth provider
func ParseUserAccount ¶
func ParseUserAccount(s string) (ua AccountKey, err error)
func (AccountKey) IsEmpty ¶ added in v0.24.0
func (ua AccountKey) IsEmpty() bool
func (AccountKey) String ¶ added in v0.10.0
func (ua AccountKey) String() string
func (AccountKey) Validate ¶ added in v0.24.0
func (ua AccountKey) Validate() error
type AccountRecord ¶
type AccountRecord interface {
AccountKey() AccountKey
AccountData() AccountData
}
type AccountsOfUser ¶
type AccountsOfUser struct {
Accounts []string `json:"accounts,omitempty" firestore:"accounts,omitempty"`
}
func (*AccountsOfUser) AddAccount ¶
func (ua *AccountsOfUser) AddAccount(userAccount AccountKey) (updates []update.Update)
func (*AccountsOfUser) GetAccount ¶
func (ua *AccountsOfUser) GetAccount(provider, app string) (userAccount *AccountKey, err error)
GetAccount returns the first account of the given provider and app.
func (*AccountsOfUser) GetAccounts ¶
func (ua *AccountsOfUser) GetAccounts(platform string) (userAccounts []AccountKey, err error)
func (*AccountsOfUser) GetFbAccount
deprecated
func (ua *AccountsOfUser) GetFbAccount(_ string) (userAccount *AccountKey, err error)
Deprecated: use GetAccount instead
func (*AccountsOfUser) GetFbAccounts
deprecated
func (ua *AccountsOfUser) GetFbAccounts() (userAccounts []AccountKey, err error)
Deprecated: use GetAccounts instead
func (*AccountsOfUser) GetFbmAccount
deprecated
func (ua *AccountsOfUser) GetFbmAccount(_ string) (userAccount *AccountKey, err error)
Deprecated: use GetAccount instead
func (*AccountsOfUser) GetGoogleAccount
deprecated
func (ua *AccountsOfUser) GetGoogleAccount() (userAccount *AccountKey, err error)
Deprecated: use GetAccounts instead
func (*AccountsOfUser) GetTelegramAccounts
deprecated
func (ua *AccountsOfUser) GetTelegramAccounts() (telegramAccounts []AccountKey, er error)
Deprecated: use GetAccounts instead
func (*AccountsOfUser) GetTelegramUserIDs ¶
func (ua *AccountsOfUser) GetTelegramUserIDs() (telegramUserIDs []int64)
func (*AccountsOfUser) HasAccount ¶
func (ua *AccountsOfUser) HasAccount(provider, app string) bool
func (*AccountsOfUser) HasGoogleAccount
deprecated
func (ua *AccountsOfUser) HasGoogleAccount() bool
Deprecated: use HasAccount instead
func (*AccountsOfUser) HasTelegramAccount
deprecated
func (ua *AccountsOfUser) HasTelegramAccount() bool
Deprecated: use HasAccount instead
func (*AccountsOfUser) RemoveAccount ¶
func (ua *AccountsOfUser) RemoveAccount(userAccount AccountKey) (changed bool)
RemoveAccount removes an account from the list of account IDs.
func (*AccountsOfUser) SetBotUserID ¶
func (ua *AccountsOfUser) SetBotUserID(platform, botID, botUserID string)
func (*AccountsOfUser) Validate ¶ added in v0.25.7
func (ua *AccountsOfUser) Validate() error
type BaseUserData ¶
type BaseUserData interface {
person.NamesHolder
with.PreferredLocaleHolder
with.CreatedTimeGetter
with.UpdatedTimeGetter
with.UpdateTimeSetter
}
BaseUserData defines base app user interface to standardize how plugins & frameworks can work with a custom app user record. The easiest way to implement this interface is to embed BaseUserFields struct into your app user record struct.
type BaseUserFields ¶
type BaseUserFields struct {
person.NameFields
with.CreatedFields
with.UpdatedFields
with.PreferredLocaleField
AccountsOfUser // TODO: Reconsider if this should be part of base implementation, if yes extend BaseUserData interface
}
BaseUserFields provides a base implementation of BaseUserData interface.
func (BaseUserFields) Validate ¶ added in v0.11.0
func (v BaseUserFields) Validate() error
type BelongsToUser ¶
type BelongsToUser interface {
GetAppUserID() (appUserID string)
SetAppUserID(appUserID string)
with.CreatedTimeGetter
with.UpdatedTimeGetter
with.UpdateTimeSetter
}
BelongsToUser should be implemented by any struct that belongs to a single user
type EmailData ¶
type EmailData struct {
EmailRaw string `firestore:"emailRaw"`
EmailLowerCase string `firestore:"emailLowerCase"`
EmailConfirmed bool `firestore:"emailConfirmed"`
}
EmailData stores info about email
func NewEmailData ¶
func (*EmailData) GetEmailConfirmed ¶
func (*EmailData) GetEmailLowerCase ¶
func (*EmailData) GetEmailRaw ¶
func (*EmailData) SetEmailConfirmed ¶
type OwnedByUserWithID ¶
type OwnedByUserWithID struct {
AppUserID string // intentionally indexed & do NOT omitempty (so we can find records with empty AppUserID)
with.CreatedFields
with.UpdatedFields
}
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) SetAppUserID ¶
func (ownedByUser *OwnedByUserWithID) SetAppUserID(appUserID string)
func (*OwnedByUserWithID) SetAppUserIntID ¶
func (ownedByUser *OwnedByUserWithID) SetAppUserIntID(appUserID int64)
func (*OwnedByUserWithID) Validate ¶
func (ownedByUser *OwnedByUserWithID) Validate() error
type WithLastLogin ¶ added in v0.21.0
WithLastLogin is a struct that contains the last login time of a user.
func (*WithLastLogin) SetLastLoginAt ¶ added in v0.21.0
func (l *WithLastLogin) SetLastLoginAt(time time.Time) update.Update
SetLastLoginAt sets the time of the last successful login.
func (*WithLastLogin) Validate ¶ added in v0.21.0
func (l *WithLastLogin) Validate() error