Documentation
¶
Index ¶
- type CreateUserOptions
- type CreateUserPayload
- type ListOptions
- type ListUsersQuery
- type ResetPasswordPayload
- type Service
- func (s *Service) CountUsers(ctx context.Context) (int, error)
- func (s *Service) Create(ctx context.Context, opts CreateUserOptions) (*models.User, error)
- func (s *Service) Deactivate(ctx context.Context, userID int) error
- func (s *Service) List(ctx context.Context, opts ListOptions) ([]*models.User, int, error)
- func (s *Service) ResetPassword(ctx context.Context, userID int, newPassword string, requirePasswordReset bool) error
- func (s *Service) Retrieve(ctx context.Context, id int) (*models.User, error)
- func (s *Service) Update(ctx context.Context, user *models.User, opts UpdateOptions) error
- func (s *Service) VerifyPassword(ctx context.Context, userID int, password string) (bool, error)
- type UpdateOptions
- type UpdateUserPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateUserOptions ¶
type CreateUserOptions struct {
Username string
Email *string
Password string
RoleID int
LibraryIDs []int
AllLibraryAccess bool
RequirePasswordReset bool
}
CreateUserOptions contains options for creating a user.
type CreateUserPayload ¶
type CreateUserPayload struct {
Username string `json:"username" validate:"required,min=3,max=50"`
Email *string `json:"email" validate:"omitempty,email"`
Password string `json:"password" validate:"required,min=8"`
RoleID int `json:"role_id" validate:"required"`
LibraryIDs []int `json:"library_ids"` // Empty means no access, special value -1 means all libraries
AllLibraryAccess bool `json:"all_library_access"` // If true, user has access to all libraries
RequirePasswordReset bool `json:"require_password_reset"`
}
CreateUserPayload represents the request body for creating a user.
type ListOptions ¶
ListOptions contains options for listing users.
type ListUsersQuery ¶
type ListUsersQuery struct {
Limit int `query:"limit" default:"50"`
Offset int `query:"offset" default:"0"`
}
ListUsersQuery represents the query parameters for listing users.
type ResetPasswordPayload ¶
type ResetPasswordPayload struct {
CurrentPassword *string `json:"current_password"` // Required for normal self-reset (not forced-reset flow)
NewPassword string `json:"new_password" validate:"required,min=8"`
RequirePasswordReset bool `json:"require_password_reset"`
}
ResetPasswordPayload represents the request body for resetting a password.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles user operations.
func RegisterRoutes ¶
RegisterRoutes registers all user routes.
func (*Service) CountUsers ¶
CountUsers returns the total number of users.
func (*Service) Deactivate ¶
Deactivate deactivates a user (soft delete).
func (*Service) ResetPassword ¶
func (s *Service) ResetPassword(ctx context.Context, userID int, newPassword string, requirePasswordReset bool) error
ResetPassword changes a user's password.
type UpdateOptions ¶
type UpdateOptions struct {
Columns []string
UpdateLibraryAccess bool
AllLibraryAccess bool
LibraryIDs []int
}
UpdateOptions contains options for updating a user.
type UpdateUserPayload ¶
type UpdateUserPayload struct {
Username *string `json:"username" validate:"omitempty,min=3,max=50"`
Email *string `json:"email" validate:"omitempty,email"`
RoleID *int `json:"role_id"`
IsActive *bool `json:"is_active"`
LibraryIDs *[]int `json:"library_ids"` // If provided, replaces library access
AllLibraryAccess *bool `json:"all_library_access"` // If true, grants access to all libraries
}
UpdateUserPayload represents the request body for updating a user.