user

package
v0.0.0-...-7a9e484 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package user provides services and types for User-related data.

Package user provides services and types for User-related data.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserExists              = errors.New("the given mail address already exists")
	ErrPasswordInvalid         = errors.New("the given password is invalid")
	ErrPasswordIncorrect       = errors.New("the given password is not correct")
	ErrUserNotStored           = errors.New("the user could not be registered")
	ErrUserNotFound            = errors.New("the user could not be found")
	ErrConfirmationMailNotSent = errors.New("confirmation mail could not be sent")
	ErrTokenInvalid            = errors.New("the confirmation token is invalid")
)

Functions

This section is empty.

Types

type Login

type Login struct {
	MailAddr string `json:"mail_addr"`
	Password string `json:"password"`
}

Login represents an user's attempt to authenticate himself.

type PaypalMailAddrSetter

type PaypalMailAddrSetter struct {
	PaypalMailAddr string `json:"paypal_mail_addr"`
}

PaypalMailAddrSetter is a setter type for the PaypalMailAddr property.

type PublicUser

type PublicUser struct {
	ID   uint64 `json:"id"`
	Name string `json:"name"`
}

PublicUser is the public representation of an user (i. e. profile).

type Registration

type Registration struct {
	MailAddr       string `json:"mail_addr"`
	Name           string `json:"name"`
	PaypalMailAddr string `json:"paypal_mail_addr"`
	Password       string `json:"password"`
}

Registration represents a user registration.

type Service

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

Service executes user-related business logic and use cases. It is also responsible for accessing the model storage under consideration of all business rules.

func NewService

func NewService(r config.Reader, u storage.User, m *mail.Service) *Service

NewService creates a new Service instance utilizing the given storage objects. The storage objects need to be ready to use for the service.

func (*Service) Authenticate

func (s *Service) Authenticate(l *Login) (uint64, error)

Authenticate will authenticate a user by comparing given login data with the stored password hash. Authenticate is not responsible for creating a session, this will be done by the session manager if the authentication was successful.

func (*Service) ConfirmMailAddr

func (s *Service) ConfirmMailAddr(token string) error

ConfirmMailAddr will confirm the mail address (and therefore the user account) that is associated with the given token.

func (*Service) Get

func (s *Service) Get(id uint64) (PublicUser, error)

Get returns all relevant meta data for an user identified by id.

func (*Service) Register

func (s *Service) Register(r *Registration) (bool, error)

Register stores a new user, creates a confirmation token and sends a corresponding confirmation e-mail.

func (*Service) SetPaypalMailAddr

func (s *Service) SetPaypalMailAddr(id uint64, setter PaypalMailAddrSetter) error

SetPaypalMailAddr sets the PayPal mail address of the user identified by id.

Jump to

Keyboard shortcuts

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