user

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteUser

func DeleteUser(id string) error

func HandleCreateUser

func HandleCreateUser(w http.ResponseWriter, r *http.Request)

HandleCreateUser godoc @Summary Create a new user @Description Registers a new user in the system @Tags users @Accept json @Produce json @Param user body UserCreateRequest true "User creation payload" @Success 201 {object} UserResponse @Failure 400 {object} model.ApiError @Failure 500 {object} model.ApiError @Router /users/create [post]

func UpdateUser

func UpdateUser(id, newEmail string) error

func ValidateUserCreateRequest

func ValidateUserCreateRequest(input UserCreateRequest) error

Types

type ApiUserResponse

type ApiUserResponse struct {
	Data  *UserResponse   `json:"data,omitempty"`
	Error *model.ApiError `json:"error,omitempty"`
}

ApiUserResponse is used for Swagger documentation

type User

type User struct {
	ID        string
	Username  string
	Password  string
	Email     string
	CreatedAt time.Time
}

func AuthenticateUser

func AuthenticateUser(username, password string) (*User, error)

AuthenticateUser checks if the provided username and password match a user in the database. It returns the user details if the credentials are valid, otherwise an error.

func UserByID

func UserByID(userID string) (*User, error)

type UserCreateRequest

type UserCreateRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Email    string `json:"email,omitempty"`
}

type UserResponse

type UserResponse struct {
	ID        string
	Username  string
	Email     string
	CreatedAt time.Time
}

func CreateUser

func CreateUser(username, password, email string) (*UserResponse, error)

Jump to

Keyboard shortcuts

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