user

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultStoragePrefix = "/supergiant/user/"

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthRequest

type AuthRequest struct {
	Login    string `json:"login"`
	Password string `json:"password"`
}

type Handler

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

func NewHandler

func NewHandler(userService *Service, tokenService TokenIssuer) *Handler

func (*Handler) Authenticate

func (h *Handler) Authenticate(w http.ResponseWriter, r *http.Request)

func (*Handler) Create

func (h *Handler) Create(rw http.ResponseWriter, r *http.Request)

func (*Handler) IsColdStart

func (h *Handler) IsColdStart(w http.ResponseWriter, r *http.Request)

func (*Handler) RegisterRootUser

func (h *Handler) RegisterRootUser(w http.ResponseWriter, r *http.Request)

type Service

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

Service contains business logic related to users

func NewService

func NewService(storagePrefix string, repository storage.Interface) *Service

NewService is a constructor function for user.Service

func (*Service) Authenticate

func (s *Service) Authenticate(ctx context.Context, username, password string) error

Authenticate checks if password stored in db is the same as in request

func (*Service) Create

func (s *Service) Create(ctx context.Context, user *User) error

Create is used to register new user

func (*Service) GetAll

func (s *Service) GetAll(ctx context.Context) ([]*User, error)

func (*Service) IsColdStart

func (s *Service) IsColdStart(ctx context.Context) (bool, error)

IsColdStart tells if any users are registered.

type TokenIssuer

type TokenIssuer interface {
	Issue(string) (string, error)
}

type User

type User struct {
	Login             string `json:"login" valid:"required, length(1|32)"`
	EncryptedPassword []byte `json:"encrypted_password" valid:"-"`
	Password          string `json:"password" valid:"required, length(8|24), printableascii"`
}

User is the representation of supergiant user

func FromJSON

func FromJSON(raw []byte) (*User, error)

func (*User) ToJSON

func (u *User) ToJSON() []byte

Jump to

Keyboard shortcuts

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