account

package
v0.12.6 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccountProto

func AccountProto(db *Account) (*account.Account, error)

AccountProto converts account db model to protobuf Account message

func AccountProtoView

func AccountProtoView(pb *account.Account, view account.AccountView) *account.Account

AccountProtoView returns the appropriate view

func NewAccountAPI

func NewAccountAPI(ctx context.Context, opt *Options) (api account.AccountAPIServer, err 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"`
	IDNumber         string `gorm:"index;type:varchar(15)"`
	Profession       string `gorm:"type:varchar(50)"`
	Residence        string `gorm:"type:varchar(100)"`
	Nationality      string `gorm:"type:varchar(50);default:'Kenyan'"`
	ProfileURL       string `gorm:"type:varchar(256)"`
	ParentId         string `gorm:"type:varchar(50)"`
	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'"`
	LastLogin        *time.Time
	CreatedAt        time.Time `gorm:"autoCreateTime"`
	UpdatedAt        time.Time `gorm:"autoUpdateTime"`
	DeletedAt        gorm.DeletedAt
}

Account contains profile information stored in the database

func AccountModel

func AccountModel(pb *account.Account) (*Account, error)

AccountModel 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
	Logger             grpclog.LoggerV2
	MessagingClient    messaging.MessagingClient
	FirebaseAuth       fauth.FirebaseAuthClient
}

Options contain parameters for NewAccountAPI

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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