Documentation
¶
Index ¶
- Variables
- type Account
- type AccountStorer
- type BasicAuthResponse
- type Token
- type TokenOption
- type TokenStorer
- type Users
- func (s *Users) BasicAuth(ctx context.Context, username, password string) (*BasicAuthResponse, error)
- func (s *Users) CreateToken(ctx context.Context, username, password string, opts TokenOption) (*Token, error)
- func (s *Users) GetAccount(ctx context.Context, id string) (*Account, bool, error)
- func (s *Users) Register(ctx context.Context, username, password string) (*Account, error)
- func (s *Users) TokenAuth(ctx context.Context, tkn string) (*Token, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAccountNotExist = errors.New("user not exist") ErrInvalidCredentials = errors.New("wrong password") ErrAccountStorer = errors.New("error account storer") ErrAccountExist = errors.New("account exist") ErrTokenNotExist = errors.New("token not exist") ErrTokenExpired = errors.New("token is expired") )
View Source
var (
Default_Token_Expire = time.Duration(24 * 7 * time.Hour) // a week
)
Functions ¶
This section is empty.
Types ¶
type Account ¶
func CreateAccount ¶
func (*Account) CheckPassword ¶
func (*Account) MustGenerateID ¶
func (acc *Account) MustGenerateID()
type AccountStorer ¶
type BasicAuthResponse ¶
type TokenOption ¶
type TokenStorer ¶
type Users ¶
type Users struct {
// contains filtered or unexported fields
}
func New ¶
func New(ctx context.Context, accounts AccountStorer, tokens TokenStorer) (*Users, error)
func NewWithMemory ¶
func NewWithMemory() *Users
func (*Users) CreateToken ¶
func (*Users) GetAccount ¶
Click to show internal directories.
Click to hide internal directories.