appuser

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 7 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountData

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

AccountData stores info about user account with auth provider

type AccountDataBase

type AccountDataBase struct {
	AccountKey
	OwnedByUserWithID
	person.NameFields
	LastLogin
	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

	FederatedIdentity string `dalgo:",noindex" datastore:",noindex"`
	FederatedProvider string `dalgo:",noindex" datastore:",noindex"`
}

func (*AccountDataBase) GetNames

func (a *AccountDataBase) GetNames() person.NameFields

func (*AccountDataBase) SetLastLogin

func (a *AccountDataBase) SetLastLogin(time time.Time)

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 user account with auth provider

func ParseUserAccount

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

func (AccountKey) String added in v0.10.0

func (ua AccountKey) String() string

type AccountRecord

type AccountRecord interface {
	Key() AccountKey
	Data() AccountData
}

type AccountsOfUser

type AccountsOfUser struct {
	Accounts []string `datastore:",noindex"`
}

func (*AccountsOfUser) AddAccount

func (ua *AccountsOfUser) AddAccount(userAccount AccountKey) (changed bool)

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(app 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(fbPageID 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 account from the list of account IDs.

func (*AccountsOfUser) SetBotUserID

func (ua *AccountsOfUser) SetBotUserID(platform, botID, botUserID string)

type BaseUserData

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 {
	//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 `json:"dtLastLogin" dalgo:"dtLastLogin" datastore:"dtLastLogin"`
}

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

Jump to

Keyboard shortcuts

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