users

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: Apache-2.0 Imports: 21 Imported by: 23

Documentation

Index

Constants

View Source
const (
	AuthenticatedUser            = authenticatedUserArgumentKey(iota)
	TagRequireUserAuthentication = "require:userauth"
)
View Source
const (
	ViewerCannot = viewerHandling(iota)
	ViewerAsSelf
	ViewerAsParent
)

Variables

View Source
var (
	ErrInvalidClaims           = errors.New("claims are invalid")
	ErrCannotReadToken         = errors.New("failed to read token")
	ErrMissingToken            = errors.New("missing or duplicate token")
	ErrFailedToValidateToken   = errors.New("failed to validate token")
	ErrMarketplaceInvalidToken = errors.New("failed to validate marketplace token")
)
View Source
var (
	ErrNotImplemented = errors.New("Not implemented")
	ErrUserNotFound   = errors.New("User not found")
	ErrUserExists     = errors.New("User already exists")
	ErrFailedCreating = errors.New("Failed to create user")
)
View Source
var (
	ErrPasswordTooShort = errors.New(fmt.Sprintf("Password must be at least %u characters.", passwordMaxLength))
)

Functions

This section is empty.

Types

type RequireAuthenticatedUser

type RequireAuthenticatedUser struct {
	ViewerHandling viewerHandling
}

func (RequireAuthenticatedUser) Decorate

type User

type User struct {
	Id                     int    `json:"id"`
	Email                  string `json:"email"`
	NextExternal           string `json:"-"`
	ParentId               *int   `json:"parentId,omitempty"`
	AwsCustomerEntitlement bool   `json:aws_customer_entitlement`
}

User is a user of the platform. It is different from models.User which is the database representation of a User.

func CreateUserWithParent

func CreateUserWithParent(ctx context.Context, db models.XODB, email string, parent User) (User, string, error)

CreateUserWithParent creates a viewer user with an email and a parent. A nil error indicates a success.

func CreateUserWithPassword

func CreateUserWithPassword(ctx context.Context, db models.XODB, email string, password string, customerIdentifier string) (User, error)

CreateUserWithPassword creates a user with an email and a password. A nil error indicates a success.

func GetUserParent

func GetUserParent(ctx context.Context, db models.XODB, user User) (parent User, err error)

func GetUserWithEmail

func GetUserWithEmail(ctx context.Context, db models.XODB, email string) (User, error)

GetUserWithEmail retrieves the user with the given unique Email. A nil error indicates a success.

func GetUserWithEmailAndPassword

func GetUserWithEmailAndPassword(ctx context.Context, db models.XODB, email string, password string) (User, error)

GetUserWithEmailAndPassword retrieves the user with the given unique Email and stored hash matching the given password. A nil eror indicates a success.

func GetUserWithId

func GetUserWithId(db models.XODB, id int) (User, error)

GetUserWithId retrieves the user with the given unique Id. A nil error indicates a success.

func GetUsersByParent

func GetUsersByParent(ctx context.Context, db models.XODB, parent User) ([]User, error)

func UpdateUserWithPassword

func UpdateUserWithPassword(ctx context.Context, tx *sql.Tx, dbUser *models.User, email string, password string) (User, error)

UpdateUserWithPassword updates a user with an email and a password. A nil error indicates a success.

func UserFromDbUser

func UserFromDbUser(dbUser models.User) User

UserFromDbUser builds a users.User from a models.User.

func (User) Delete

func (u User) Delete() error

Delete deletes the user. A nil error indicates a success.

func (User) PasswordMatches

func (u User) PasswordMatches(password string) error

PasswordMatches tests whether a password matches a user's stored hash. A nil error indicates a match.

func (User) UpdateNextExternal

func (u User) UpdateNextExternal(ctx context.Context, db models.XODB) error

func (User) UpdatePassword

func (u User) UpdatePassword(db models.XODB, password string) error

UpdatePassword updates a user's password. A nil error indicates a success.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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