user

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Code generated by fertilize; DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var (
	RoleAdmin = Role{"ADMIN"}
	RoleUser  = Role{"USER"}
)

Set of possible roles for a user.

Functions

This section is empty.

Types

type AuthenticateRequest

type AuthenticateRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type AuthenticateResponse

type AuthenticateResponse struct {
	Token string `json:"token"`
	Error string `json:"error,omitempty"`
}

type CreateUserRequest

type CreateUserRequest struct {
	NewUser NewUser `json:"newUser"`
}

CreateUserRequest is the request object for UserService.CreateUser.

type CreateUserResponse

type CreateUserResponse struct {
	User  User   `json:"user"`
	Error string `json:"error,omitempty"`
}

CreateUserResponse is the response object containing a UserService.CreateUser.

type DeleteUserRequest

type DeleteUserRequest struct {
	User User `json:"user"`
}

DeleteUserRequest is the request object for UserService.DeleteUser.

type DeleteUserResponse

type DeleteUserResponse struct {
	User  User   `json:"user"`
	Error string `json:"error,omitempty"`
}

DeleteUserResponse is the response object for UserService.DeleteUser.

type NewUser

type NewUser struct {
	Name            string       `json:"name"`
	Email           mail.Address `json:"email"`
	Roles           []Role       `json:"roles"`
	Department      string       `json:"department"`
	Password        string       `json:"password"`
	PasswordConfirm string       `json:"password_confirm"`
}

NewUser contains information needed to create a new user.

type QueryUserByEmailRequest

type QueryUserByEmailRequest struct {
	Email string `json:"email"`
}

QueryUserByEmailRequest is the request object for UserService.QueryUserByEmail.

type QueryUserByEmailResponse

type QueryUserByEmailResponse struct {
	User  User   `json:"user"`
	Error string `json:"error,omitempty"`
}

QueryUserByEmailResponse is the response object for UserService.QueryUserByEmail.

type QueryUserByIDRequest

type QueryUserByIDRequest struct {
	ID string `json:"id"`
}

QueryUserByIDRequest is the request object for UserService.QueryUserByID.

type QueryUserByIDResponse

type QueryUserByIDResponse struct {
	User  User   `json:"user"`
	Error string `json:"error,omitempty"`
}

QueryUserByIDResponse is the response object for UserService.QueryUserByID.

type QueryUserRequest

type QueryUserRequest struct{}

type QueryUserResponse

type QueryUserResponse struct{}

type Role

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

Role represents a role in the system.

func MustParseRole

func MustParseRole(value string) Role

MustParseRole parses the string value and returns a role if one exists. If an error occurs the function panics.

func ParseRole

func ParseRole(value string) (Role, error)

ParseRole parses the string value and returns a role if one exists.

func (Role) Equal

func (r Role) Equal(r2 Role) bool

Equal provides support for the go-cmp package and testing.

func (Role) MarshalText

func (r Role) MarshalText() ([]byte, error)

MarshalText implement the marshal interface for JSON conversions.

func (Role) Name

func (r Role) Name() string

Name returns the name of the role.

func (*Role) UnmarshalText

func (r *Role) UnmarshalText(data []byte) error

UnmarshalText implement the unmarshal interface for JSON conversions.

type Storer

type Storer interface {
	Create(ctx context.Context, usr User) (User, error)
	Delete(ctx context.Context, email mail.Address) (User, error)
	QueryByID(ctx context.Context, id string) (User, error)
	QueryByEmail(ctx context.Context, email string) (User, error)
	Update(ctx context.Context, usr UpdateUser) (User, error)
	Authenticate(ctx context.Context, email string, password string) (User, error)
}

Storer interface declares the behavior this package needs to perists and retrieve data.

type UpdateUser

type UpdateUser struct {
	Name            *string       `json:"name"`
	Email           *mail.Address `json:"email"`
	Roles           []Role        `json:"roles"`
	Department      *string       `json:"department"`
	Password        *string       `json:"passowrd"`
	PasswordConfirm *string       `json:"password_confirm"`
	Enabled         *bool         `json:"enabled"`
}

UpdateUser contains information needed to update a user.

type UpdateUserRequest

type UpdateUserRequest struct {
	UpdateUser UpdateUser `json:"user"`
}

type UpdateUserResponse

type UpdateUserResponse struct {
	User  User   `json:"user"`
	Error string `json:"error,omitempty"`
}

type User

type User struct {
	ID           uuid.UUID    `json:"id"`
	Name         string       `json:"name"`
	Email        mail.Address `json:"email"`
	Roles        []Role       `json:"roles"`
	PasswordHash []byte       `json:"password_hash"`
	Department   string       `json:"department"`
	Enabled      bool         `json:"enabled"`
	DateCreated  time.Time    `json:"date_created"`
	DateUpdated  time.Time    `json:"date_updated"`
}

User represents information about an individual user.

type UserRpcService

type UserRpcService interface {
	UserService
	// Registers RPCService with Server
	Register(s *server.Server)
}

Required to register endpoints with the Server

func NewUserServicer

func NewUserServicer(log *zap.SugaredLogger, storer Storer, a auth.Auth) UserRpcService

Create new UserServicer

type UserService

type UserService interface {
	// CreateUser create a user
	CreateUser(CreateUserRequest, server.GenericRequest) CreateUserResponse
	// UpdateUser updates a user
	UpdateUser(UpdateUserRequest, server.GenericRequest) UpdateUserResponse
	// DeleteUser deletes a user
	DeleteUser(DeleteUserRequest, server.GenericRequest) DeleteUserResponse
	// QueryUser retrieves a list of existing users
	QueryUser(QueryUserRequest, server.GenericRequest) QueryUserResponse
	// QueryByID gets the specified user by id
	QueryUserByID(QueryUserByIDRequest, server.GenericRequest) QueryUserByIDResponse
	// QueryByEmail gets the specified user by email
	QueryUserByEmail(QueryUserByEmailRequest, server.GenericRequest) QueryUserByEmailResponse
	// Authenticate finds a user by their email and verifies their password. On
	// success it returns a Claims User representing this user. The claims can be
	// used to generate a token for future authentication.
	Authenticate(AuthenticateRequest, server.GenericRequest) AuthenticateResponse
}

UserService is an API for creating users for an app.

type UserServicer

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

Implements interface

func (UserServicer) Authenticate

Authenticate implements UserRpcService

func (UserServicer) AuthenticateHandler

func (h UserServicer) AuthenticateHandler(r server.GenericRequest, b []byte) (any, error)

AuthenticateHandler validates input data prior to calling Authenticate

func (UserServicer) CreateUser

CreateUser implements UserRpcService

func (UserServicer) CreateUserHandler

func (h UserServicer) CreateUserHandler(r server.GenericRequest, b []byte) (any, error)

CreateUserHandler validates input data prior to calling CreateUser

func (UserServicer) DeleteUser

DeleteUser implements UserRpcService

func (UserServicer) DeleteUserHandler

func (h UserServicer) DeleteUserHandler(r server.GenericRequest, b []byte) (any, error)

DeleteUserHandler validates input data prior to calling DeleteUser

func (UserServicer) QueryUser

QueryUser implements UserRpcService

func (UserServicer) QueryUserByEmail

QueryUserByEmail implements UserRpcService

func (UserServicer) QueryUserByEmailHandler

func (h UserServicer) QueryUserByEmailHandler(r server.GenericRequest, b []byte) (any, error)

QueryUserByEmailHandler validates input data prior to calling QueryUserByEmail

func (UserServicer) QueryUserByID

QueryUserByID implements UserRpcService

func (UserServicer) QueryUserByIDHandler

func (h UserServicer) QueryUserByIDHandler(r server.GenericRequest, b []byte) (any, error)

QueryUserByIDHandler validates input data prior to calling QueryUserByID

func (UserServicer) QueryUserHandler

func (h UserServicer) QueryUserHandler(r server.GenericRequest, b []byte) (any, error)

QueryUserHandler validates input data prior to calling QueryUser

func (UserServicer) Register

func (us UserServicer) Register(s *server.Server)

Register implements UserRpcService

func (UserServicer) UpdateUser

UpdateUser implements UserRpcService

func (UserServicer) UpdateUserHandler

func (h UserServicer) UpdateUserHandler(r server.GenericRequest, b []byte) (any, error)

UpdateUserHandler validates input data prior to calling UpdateUser

Directories

Path Synopsis
stores

Jump to

Keyboard shortcuts

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