auth

package
v0.0.0-...-b8189d2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserCollection    = "users"
	UserEmailField    = "email"
	UserPasswordField = "password"
)

Variables

This section is empty.

Functions

func CountUserByEmail

func CountUserByEmail(ctx context.Context, email string) (int64, error)

func InsertUser

func InsertUser(ctx context.Context, user *User) error

func Login

func UpdateUser

func UpdateUser(ctx context.Context, user *User) error

func VerifyPassword

func VerifyPassword(storedPassword *HashedPassword, inputPassword string) error

Types

type HashedPassword

type HashedPassword struct {
	Hash string `bson:"hash"`
	Salt string `bson:"salt"`
}

func GeneratePassword

func GeneratePassword(rawPassword string) (*HashedPassword, error)

type User

type User struct {
	ID        string         `bson:"_id"`
	Username  string         `bson:"username"`
	Email     string         `bson:"email"`
	Password  HashedPassword `bson:"password"`
	Avatar    string         `bson:"avatar"`
	CreatedAt time.Time      `bson:"created_at"`
	UpdatedAt time.Time      `bson:"updated_at"`
}

func GetUserByEmail

func GetUserByEmail(ctx context.Context, email string) (*User, error)

Jump to

Keyboard shortcuts

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