appuser

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
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

func ParseUserAccount(s string) (ua Account, err error)

func (Account) String

func (ua Account) String() string

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

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 CreatedTimeGetter interface {
	GetCreatedTime() time.Time
}

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 NewEmailData(email string) EmailData

func (*EmailData) GetEmailConfirmed

func (ed *EmailData) GetEmailConfirmed() bool

func (*EmailData) GetEmailLowerCase

func (ed *EmailData) GetEmailLowerCase() string

func (*EmailData) GetEmailRaw

func (ed *EmailData) GetEmailRaw() string

func (*EmailData) SetEmailConfirmed

func (ed *EmailData) SetEmailConfirmed(value bool)

func (*EmailData) Validate

func (ed *EmailData) Validate() error

type LastLogin

type LastLogin struct {
	DtLastLogin time.Time `datastore:",omitempty"`
}

LastLogin is a struct that contains the last login time of a user.

func (*LastLogin) SetLastLogin

func (l *LastLogin) SetLastLogin(time time.Time)

SetLastLogin sets the last login time of a user.

type Name

type Name struct {
	Field name
	Value string
}

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

Jump to

Keyboard shortcuts

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