users

package
v0.0.0-...-bbf7e2a Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FetchUserByEmailQuery = "SELECT id, username, salt, pass_hash, user_type FROM users WHERE email = $1"
)

Variables

This section is empty.

Functions

func GenerateJWT

func GenerateJWT(email string, id string, userType int32) (string, error)

func NewGrpcServer

func NewGrpcServer(port string, s UsersService) *grpc.Server

func NewSqlDb

func NewSqlDb(dburl string) (*sql.DB, error)

func NewUsersServer

func NewUsersServer(s UsersService) proto.UserServiceServer

Types

type CustomClaims

type CustomClaims struct {
	UserType int32  `json:"user_type"`
	Id       string `json:"id"`
	jwt.RegisteredClaims
}

type DetailedUser

type DetailedUser struct {
	Id       uuid.UUID
	Username string
	Email    string
	Salt     string
	PassHash string
	UserType int32
}

type EventProducer

type EventProducer interface {
	Produce(key string, data []byte)
}

func NewEventProducer

func NewEventProducer(exchange string, ch *amqp.Channel) EventProducer

type LoginRequest

type LoginRequest struct {
	Email    string
	Password string
}

type RegisterUserRequest

type RegisterUserRequest struct {
	Username string
	Email    string
	Password string
	UserType int32
}

type User

type User struct {
	Id       uuid.UUID
	Username string
	Email    string
	UserType int32
}

type UsersRepository

type UsersRepository interface {
	FetchUser(id uuid.UUID) (*DetailedUser, error)
	FetchUserByEmail(email string) (*DetailedUser, error)
	FetchAllUsers() ([]*User, error)
	RegisterUser(id uuid.UUID, username string, email string, salt string, passHash string, userType int32) error
}

func NewUsersRepository

func NewUsersRepository(db *sql.DB) UsersRepository

type UsersService

type UsersService interface {
	GetUser(id string) (*User, error)
	GetAllUsers() ([]*User, error)
	LoginUser(LoginRequest) (*string, error)
	RegisterUser(req RegisterUserRequest) (*uuid.UUID, error)
}

func NewUsersService

func NewUsersService(repo UsersRepository, p EventProducer) UsersService

Jump to

Keyboard shortcuts

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