user

package
v0.0.0-...-e5a9a76 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2015 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BSONUser

type BSONUser struct {
	Id         string
	Passkey    string
	Token      string
	Namespaces []string
}

type DuplicatedIdError

type DuplicatedIdError struct {
	Id Id
}

func (DuplicatedIdError) Error

func (DuplicatedIdError) Error() string

type Encryptor

type Encryptor interface {
	Encrypt(string) string
}

type Factory

type Factory struct {
	Encryptor PasskeyEncryptor
}

func (Factory) Make

func (f Factory) Make(id Id, passkey string) User

type Id

type Id uuid.UUID

func ParseId

func ParseId(s string) (i Id)

func (Id) Equal

func (i Id) Equal(i2 Id) bool

func (Id) IsEmpty

func (i Id) IsEmpty() bool

func (Id) Serialize

func (i Id) Serialize() string

type IncorrectNamespaceError

type IncorrectNamespaceError struct {
	User      User
	Namespace Namespace
}

func (IncorrectNamespaceError) Error

type IncorrectPasskeyError

type IncorrectPasskeyError struct{}

func (IncorrectPasskeyError) Error

func (IncorrectPasskeyError) Error() string

type Login

type Login struct {
	Validator  SignInValidator
	UserSource Source
}

func (Login) Try

func (l Login) Try(uid Id, p string, n Namespace) (u *User, err error)

type Namespace

type Namespace string

func (Namespace) Equal

func (n Namespace) Equal(n2 Namespace) bool

func (Namespace) Owns

func (n Namespace) Owns(no Namespace) bool

type NotExistentUser

type NotExistentUser struct {
	Id Id
}

func (NotExistentUser) Error

func (NotExistentUser) Error() string

type Passkey

type Passkey string

type PasskeyEncryptor

type PasskeyEncryptor struct {
	Encryptor Encryptor
}

func (PasskeyEncryptor) Encrypt

func (pe PasskeyEncryptor) Encrypt(id Id, passkey string) Passkey

type SignInValidator

type SignInValidator struct {
	Encryptor PasskeyEncryptor
}

func (SignInValidator) Validate

func (suv SignInValidator) Validate(u User, p string) error

type Source

type Source interface {
	Add(*User) error
	Get(Id) (*User, error)
}

type Token

type Token uuid.UUID

func GenerateToken

func GenerateToken() Token

func ParseToken

func ParseToken(s string) Token

func (Token) IsEmpty

func (t Token) IsEmpty() bool

func (Token) IsSame

func (t Token) IsSame(t2 Token) bool

func (Token) Serialize

func (t Token) Serialize() string

type User

type User struct {
	Token Token
	// contains filtered or unexported fields
}

func New

func New(i Id, p Passkey) User

func (User) CheckToken

func (u User) CheckToken(t Token) bool

func (*User) GenerateToken

func (u *User) GenerateToken()

func (User) GetBSON

func (u User) GetBSON() (bu interface{}, err error)

func (*User) GrantAccessTo

func (u *User) GrantAccessTo(n Namespace)

func (User) HasAccessTo

func (u User) HasAccessTo(n Namespace) bool

func (User) HasToken

func (u User) HasToken() bool

func (User) Id

func (u User) Id() Id

func (User) Passkey

func (u User) Passkey() Passkey

func (*User) SetBSON

func (u *User) SetBSON(raw bson.Raw) (err error)

type UserSourceTests

type UserSourceTests struct {
	Source    func() Source
	AfterEach func()
}

func (UserSourceTests) Run

func (ut UserSourceTests) Run(t *t.T)

func (UserSourceTests) TestGettingAUserIfNotExistsShouldReturnAError

func (ust UserSourceTests) TestGettingAUserIfNotExistsShouldReturnAError(t *t.T)

func (UserSourceTests) TestShouldReturnTheSameUserAsAdded

func (ust UserSourceTests) TestShouldReturnTheSameUserAsAdded(t *t.T)

func (UserSourceTests) TestWhenAddingAUserIfIdExistsShouldReturnError

func (ust UserSourceTests) TestWhenAddingAUserIfIdExistsShouldReturnError(t *t.T)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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