user

package
v0.0.0-...-37efa2e Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoDBUserRepository

type MongoDBUserRepository struct {
	// contains filtered or unexported fields
}

MongoDBUserRepository is an implementation of the UserRepository interface using MongoDB.

func NewMongoDBUserRepository

func NewMongoDBUserRepository(client *mongo.Client, dbName, collectionName string) *MongoDBUserRepository

NewMongoDBUserRepository creates a new MongoDB-backed user repository.

func (*MongoDBUserRepository) GetByEmail

func (r *MongoDBUserRepository) GetByEmail(ctx context.Context, email string) (*User, error)

GetByEmail retrieves a user from MongoDB by their email.

func (*MongoDBUserRepository) Save

func (r *MongoDBUserRepository) Save(ctx context.Context, user *User) error

Save saves a new user to MongoDB.

type User

type User struct {
	ID       primitive.ObjectID `bson:"_id,omitempty"`
	Name     string             `bson:"name"`
	Email    string             `bson:"email"`
	Password string             `bson:"password"`
	Photo    string             `bson:"photo"`
}

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func NewUserService

func NewUserService(repo *MongoDBUserRepository, authService *auth.JWTService) *UserService

func (*UserService) Login

func (u *UserService) Login(email, password string) (*User, error)

Login handles user login.

func (*UserService) Register

func (u *UserService) Register(user User) error

Register handles user registration.

Jump to

Keyboard shortcuts

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