user

package
v0.0.0-...-8de5691 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyPassword = errors.New("empty password")
)

define errors.

Functions

This section is empty.

Types

type DeleteAccountTimeType

type DeleteAccountTimeType int
const (
	OneMonth DeleteAccountTimeType = iota + 1
	ThreeMonth
	SixMonth
)

type Device

type Device struct {
	ID       string `bson:"id" json:"id"`
	Name     string `bson:"name" json:"name"`
	IP       string `bson:"ip" json:"ip"`
	Location string `bson:"location" json:"location"`
}

type Profile

type Profile struct {
	Biography     string         `bson:"biography" json:"biography"`
	ProfilePhotos []ProfilePhoto `bson:"profile_photos" json:"profilePhotos"`
	Devices       []Device       `bson:"devices" json:"devices"`
	Contacts      []string       `bson:"contacts" json:"contacts"`
	BlockedUsers  []string       `bson:"blocked_users" json:"blockedUsers"`
	Setting       Setting        `bson:"setting" json:"setting"`
	LastSeen      time.Time      `bson:"last_seen" json:"lastSeen"`
}

type ProfilePhoto

type ProfilePhoto struct {
	ID    string `bson:"id" json:"id"`
	Name  string `bson:"name" json:"name"`
	Order int    `bson:"order" json:"order"`
}

type Setting

type Setting struct {
	ShowLastSeen      bool                  `bson:"show_last_seen" json:"showLastSeen"`
	TwoFA             bool                  `bson:"two_fa" json:"twoFa"`
	DeleteAccountTime DeleteAccountTimeType `bson:"delete_account_time" json:"deleteAccountTime"`
}

type User

type User struct {
	StaticID  primitive.ObjectID `bson:"id"        json:"id"`
	Name      string             `bson:"name" json:"name"`
	LastName  string             `bson:"last_name"  json:"lastName"`
	Phone     string             `bson:"phone" json:"phone"`
	Username  string             `bson:"username" json:"username"`
	Banned    bool               `bson:"banned" json:"banned"`
	Profile   Profile            `bson:"profile" json:"profile"`
	CreatedAt time.Time          `bson:"created_at" json:"createdAt"`
	UpdatedAt time.Time          `bson:"updated_at" json:"updatedAt"`
}

func NewUser

func NewUser(phone string) *User

func (*User) FullName

func (u *User) FullName() string

func (User) IsBanned

func (u User) IsBanned() bool

type UserRepository

type UserRepository interface {
	Create(user *User) (*User, error)
	Where(filter bson.M) ([]*User, error)
	FindByID(staticID primitive.ObjectID) (*User, error)
	FindByUsername(username string) (*User, error)
	FindByPhone(phone string) (*User, error)
}

type UserService

type UserService interface {
	Login(phone string) (int, error)
	VerifyOTP(phone string, otp int) (*session.LoginTokens, error)
	RefreshToken(refreshToken string, accessToken string) (string, error)
	Authenticate(accessToken string) (*User, error)
}

Jump to

Keyboard shortcuts

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