account

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2021 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAccountPB added in v0.6.0

func GetAccountPB(accountDB *Account) (*account.Account, error)

GetAccountPB converts account db model to protobuf Account message

func GetAccountPBView added in v0.6.0

func GetAccountPBView(accountPB *account.Account, view account.AccountView) *account.Account

GetAccountPBView returns the appropriate view

func NewAccountAPI

func NewAccountAPI(ctx context.Context, opt *Options) (account.AccountAPIServer, error)

NewAccountAPI creates an account API singleton

Types

type Account

type Account struct {
	AccountID        uint   `gorm:"primaryKey;autoIncrement"`
	ProjectID        string `gorm:"index;type:varchar(50);not null"`
	Email            string `gorm:"index;type:varchar(50);not null"`
	Phone            string `gorm:"index;type:varchar(50);not null"`
	DeviceToken      string `gorm:"type:varchar(256)"`
	Names            string `gorm:"type:varchar(50);not null"`
	BirthDate        string `gorm:"type:varchar(30);"`
	Gender           string `gorm:"index;type:enum('GENDER_UNSPECIFIED', 'MALE', 'FEMALE');default:'GENDER_UNSPECIFIED';not null"`
	Nationality      string `gorm:"type:varchar(50);default:'Kenyan'"`
	ProfileURL       string `gorm:"type:varchar(256)"`
	LinkedAccounts   string `gorm:"type:varchar(256)"`
	SecurityQuestion string `gorm:"type:varchar(50)"`
	SecurityAnswer   string `gorm:"type:varchar(50)"`
	Password         string `gorm:"type:text"`
	PrimaryGroup     string `gorm:"index;type:varchar(50);not null"`
	SecondaryGroups  []byte `gorm:"type:json"`
	AccountState     string `gorm:"index;type:enum('BLOCKED','ACTIVE', 'INACTIVE');not null;default:'INACTIVE'"`
	CreatedAt        time.Time
	UpdatedAt        time.Time
	DeletedAt        gorm.DeletedAt
}

Account contains profile information stored in the database

func GetAccountDB added in v0.6.0

func GetAccountDB(accountPB *account.Account) (*Account, error)

GetAccountDB converts protobuf Account message to account db model

func (*Account) AfterCreate

func (u *Account) AfterCreate(tx *gorm.DB) error

AfterCreate is a callback after creating object

func (*Account) AfterFind

func (u *Account) AfterFind(tx *gorm.DB) (err error)

AfterFind will reset email and phone to their zero value if they equal the accoint id

func (*Account) TableName

func (u *Account) TableName() string

TableName is the name of the tables

type Options

type Options struct {
	AppName            string
	EmailDisplayName   string
	DefaultEmailSender string
	TemplatesDir       string
	ActivationURL      string
	PaginationHasher   *hashids.HashID
	AuthAPI            auth.API
	SQLDBWrites        *gorm.DB
	SQLDBReads         *gorm.DB
	RedisDBWrites      *redis.Client
	RedisDBReads       *redis.Client
	SecureCookie       *securecookie.SecureCookie
	Logger             grpclog.LoggerV2
	MessagingClient    messaging.MessagingClient
	FirebaseAuth       fauth.FirebaseAuthClient
}

Options contain parameters for NewAccountAPI

Jump to

Keyboard shortcuts

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