users

package
v0.0.0-...-d40265a Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingFields    = fmt.Errorf("not all fields are provided")
	ErrInvalidOrgnName  = fmt.Errorf("organization name does not follow policies")
	ErrWrongCredentials = fmt.Errorf("user credentials are not matching with db record")

	ErrInvalidJWT = fmt.Errorf("jwt is no longer valid")
	ErrJWTParse   = fmt.Errorf("could not parse jwt token")
	ErrCorruptJWT = fmt.Errorf("jwt could not be parsed (JWT might be corrupted)")
	ErrExpiredJWT = fmt.Errorf("provided JWT has expired")
)

Functions

This section is empty.

Types

type AuthedUser

type AuthedUser struct {
	Uuid         string
	Organization string
	Username     string
}

func LoggedIn

func LoggedIn(accessToken string) (*AuthedUser, error)

type User

type User struct {
	Uuid         string `bson:"_id"`
	Username     string `bson:"username" required:"yes"`
	Organization string `bson:"organization" required:"yes"`
	Password     string `bson:"password"`
}

func NewDefaultUser

func NewDefaultUser(username, organization string) (*User, error)

func (User) AccessToken

func (u User) AccessToken() (string, error)

AccessToken generates a JWT based on the User information

func (User) Credentials

func (u User) Credentials(password string) error

func (*User) HashAndSalt

func (u *User) HashAndSalt(password string) error

HashAndSalt hashes the plain text user password

func (*User) UUID

func (u *User) UUID() error

UUID assigns a new unique identifier to the User struct

type UserRepo

type UserRepo interface {
	UsernameTaken(ctx context.Context, username string) (bool, error)
	Store(ctx context.Context, user User) error
	GetByUsername(ctx context.Context, username string, stored interface{}) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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