models

package
v0.0.0-...-6436baa Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventsRepository

type EventsRepository interface {
	PublishUserUpdated(ctx context.Context, u *User, isNewUser bool) error
}

type IDToken

type IDToken struct {
	SS string `json:"idToken"`
}

IDToken stores token properties that are accessed in multiple application layers

type ImageRepository

type ImageRepository interface {
	DeleteProfile(ctx context.Context, objName string) error
	UpdateProfile(ctx context.Context, objName string, imageFile multipart.File) (string, error)
}

ImageRepository defines methods the service layer expects the repositories it interacts with to implement

type RefreshToken

type RefreshToken struct {
	ID  uuid.UUID `json:"-"`
	UID uuid.UUID `json:"-"`
	SS  string    `json:"refreshToken"`
}

RefreshToken stores token properties that are accessed in multiple application layers

type TokenPair

type TokenPair struct {
	IDToken
	RefreshToken
}

TokenPair used for returning pairs of id and refresh tokens

type TokenRepository

type TokenRepository interface {
	SetRefreshToken(ctx context.Context, userID string, tokenID string, expiresIn time.Duration) error
	DeleteRefreshToken(ctx context.Context, userID string, prevTokenID string) error
	DeleteUserRefreshTokens(ctx context.Context, userID string) error
}

TokenRepository defines methods the service layer expects the repositories it interacts with to implement

type TokenService

type TokenService interface {
	NewPairFromUser(ctx context.Context, u *User, prevTokenID string) (*TokenPair, error)
	Signout(ctx context.Context, uid uuid.UUID) error
	ValidateIDToken(tokenString string) (*User, error)
	ValidateRefreshToken(refreshTokenString string) (*RefreshToken, error)
}

TokenService defines methods the handler later expects to interact with to produce JWT's as string

type User

type User struct {
	UID       uuid.UUID `db:"uid" json:"uid"`
	Email     string    `db:"email" json:"email"`
	Password  string    `db:"password" json:"-"`
	Name      string    `db:"name" json:"name"`
	ImageURL  string    `db:"image_url" json:"imageUrl"`
	Website   string    `db:"website" json:"website"`
	CreatedAt time.Time `db:"created_at" json:"createdAt"`
	UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
}

type UserRepository

type UserRepository interface {
	FindByID(ctx context.Context, uid uuid.UUID) (*User, error)
	FindByEmail(ctx context.Context, email string) (*User, error)
	Create(ctx context.Context, u *User) error
	Update(ctx context.Context, u *User) error
	UpdateImage(ctx context.Context, uid uuid.UUID, imageURL string) (*User, error)
}

UserRepository defines methods the service layer expects the repositories it interacts with to implement

type UserService

type UserService interface {
	Get(ctx context.Context, uid uuid.UUID) (*User, error)
	Signup(ctx context.Context, u *User) error
	Signin(ctx context.Context, u *User) error
	UpdateDetails(ctx context.Context, u *User) error
	SetProfileImage(ctx context.Context, uid uuid.UUID, imageFileHeader *multipart.FileHeader) (*User, error)
	ClearProfileImage(ctx context.Context, uid uuid.UUID) error
}

UserService defines methods the handler layer expects the service it interacts with to implement

Jump to

Keyboard shortcuts

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