Documentation ¶
Index ¶
- Constants
- Variables
- type RequireAuthenticatedUser
- type User
- func CreateUserWithParent(ctx context.Context, db models.XODB, email string, parent User) (User, string, error)
- func CreateUserWithPassword(ctx context.Context, db models.XODB, email string, password string, ...) (User, error)
- func GetUserParent(ctx context.Context, db models.XODB, user User) (parent User, err error)
- func GetUserWithEmail(ctx context.Context, db models.XODB, email string) (User, error)
- func GetUserWithEmailAndPassword(ctx context.Context, db models.XODB, email string, password string) (User, error)
- func GetUserWithId(db models.XODB, id int) (User, error)
- func GetUsersByParent(ctx context.Context, db models.XODB, parent User) ([]User, error)
- func UpdateUserWithPassword(ctx context.Context, tx *sql.Tx, dbUser *models.User, email string, ...) (User, error)
- func UserFromDbUser(dbUser models.User) User
Constants ¶
const ( AuthenticatedUser = authenticatedUserArgumentKey(iota) TagRequireUserAuthentication = "require:userauth" )
const ( ViewerCannot = viewerHandling(iota) ViewerAsSelf ViewerAsParent )
Variables ¶
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") )
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") )
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
}
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 GetUserWithEmail ¶
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 ¶
GetUserWithId retrieves the user with the given unique Id. A nil error indicates a success.
func GetUsersByParent ¶
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 ¶
UserFromDbUser builds a users.User from a models.User.
func (User) PasswordMatches ¶
PasswordMatches tests whether a password matches a user's stored hash. A nil error indicates a match.