user

package
v0.6.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

This section is empty.

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 added in v0.0.4

type AccountData interface {
	BelongsToUser
	GetEmailLowerCase() string
	GetEmailConfirmed() bool
	SetLastLogin(time time.Time)
	GetNames() Names
}

AccountData stores info about user account with auth provider

type AccountDataBase added in v0.5.0

type AccountDataBase struct {
	Account
	OwnedByUserWithID
	Names
	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 added in v0.5.0

func (a *AccountDataBase) GetNames() Names

func (*AccountDataBase) SetLastLogin added in v0.5.0

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 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 BelongsToUserWithIntID

type BelongsToUserWithIntID interface {
	BelongsToUser
	GetAppUserIntID() (appUserID int64)
	SetAppUserIntID(appUserID int64)
}

BelongsToUserWithIntID is deprecated. Remove once OwnedByUserWithID.AppUserIntID is removed.

type EmailData added in v0.5.5

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 added in v0.5.5

func NewEmailData(email string) EmailData

func (*EmailData) GetEmailConfirmed added in v0.5.5

func (ed *EmailData) GetEmailConfirmed() bool

func (*EmailData) GetEmailLowerCase added in v0.5.5

func (ed *EmailData) GetEmailLowerCase() string

func (*EmailData) GetEmailRaw added in v0.5.5

func (ed *EmailData) GetEmailRaw() string

func (*EmailData) SetEmailConfirmed added in v0.5.5

func (ed *EmailData) SetEmailConfirmed(value bool)

func (*EmailData) Validate added in v0.5.5

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 Names

type Names struct {
	FirstName string `datastore:",noindex"`
	LastName  string `datastore:",noindex"`
	NickName  string `datastore:",noindex"`
}

func (Names) GetNames

func (entity Names) GetNames() Names

type OwnedByUserWithID added in v0.3.1

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 added in v0.4.1

func NewOwnedByUserWithID(id string, created time.Time) OwnedByUserWithID

NewOwnedByUserWithID creates a new OwnedByUserWithID, takes user ID and time of creation

func (*OwnedByUserWithID) GetAppUserID added in v0.3.1

func (ownedByUser *OwnedByUserWithID) GetAppUserID() string

func (*OwnedByUserWithID) GetAppUserIntID added in v0.3.1

func (ownedByUser *OwnedByUserWithID) GetAppUserIntID() int64

func (*OwnedByUserWithID) GetCreatedTime added in v0.5.0

func (ownedByUser *OwnedByUserWithID) GetCreatedTime() time.Time

func (*OwnedByUserWithID) GetUpdatedTime added in v0.5.0

func (ownedByUser *OwnedByUserWithID) GetUpdatedTime() time.Time

func (*OwnedByUserWithID) SetAppUserID added in v0.3.1

func (ownedByUser *OwnedByUserWithID) SetAppUserID(appUserID string)

func (*OwnedByUserWithID) SetAppUserIntID added in v0.3.1

func (ownedByUser *OwnedByUserWithID) SetAppUserIntID(appUserID int64)

func (*OwnedByUserWithID) SetCreatedTime added in v0.3.1

func (ownedByUser *OwnedByUserWithID) SetCreatedTime(v time.Time)

func (*OwnedByUserWithID) SetUpdatedTime added in v0.3.1

func (ownedByUser *OwnedByUserWithID) SetUpdatedTime(v time.Time)

func (*OwnedByUserWithID) Validate added in v0.3.1

func (ownedByUser *OwnedByUserWithID) Validate() error

Jump to

Keyboard shortcuts

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