user

package
v0.0.0-...-5cbc45b Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ProviderReearth = "reearth"
	ProviderAuth0   = "auth0"
)

Variables

View Source
var (
	DefaultPasswordEncoder PasswordEncoder = &BcryptPasswordEncoder{}
	ErrEncodingPassword                    = rerror.NewE(i18n.T("encoding password"))
	ErrInvalidPassword                     = rerror.NewE(i18n.T("invalid password"))
	ErrPasswordLength                      = rerror.NewE(i18n.T("password at least 8 characters"))
	ErrPasswordUpper                       = rerror.NewE(i18n.T("password should have upper case letters"))
	ErrPasswordLower                       = rerror.NewE(i18n.T("password should have lower case letters"))
	ErrPasswordNumber                      = rerror.NewE(i18n.T("password should have numbers"))
)
View Source
var (
	ErrInvalidEmail = errors.New("invalid email")
)
View Source
var ErrInvalidName = rerror.NewE(i18n.T("invalid user name"))
View Source
var GenerateVerificationCode = generateCode
View Source
var WorkspaceIDFrom = accountdomain.WorkspaceIDFrom
View Source
var WorkspaceIDFromRef = accountdomain.WorkspaceIDFromRef

Functions

func MockGenerateVerificationCode

func MockGenerateVerificationCode(code string) func()

func ValidatePasswordFormat

func ValidatePasswordFormat(pass string) error

Types

type Auth

type Auth struct {
	Provider string
	Sub      string
}

func AuthFrom

func AuthFrom(sub string) Auth

func GenReearthSub

func GenReearthSub(userID string) *Auth

func NewReearthAuth

func NewReearthAuth(sub string) Auth

func ReearthSub

func ReearthSub(userID string) *Auth

func (Auth) IsAuth0

func (a Auth) IsAuth0() bool

func (Auth) IsReearth

func (a Auth) IsReearth() bool

func (Auth) Ref

func (a Auth) Ref() *Auth

func (Auth) String

func (a Auth) String() string

type Auths

type Auths []Auth

func (Auths) Add

func (a Auths) Add(u Auth) Auths

func (Auths) Get

func (a Auths) Get(sub string) *Auth

func (Auths) GetByProvider

func (a Auths) GetByProvider(p string) *Auth

func (Auths) Has

func (a Auths) Has(sub string) bool

func (Auths) HasProvider

func (a Auths) HasProvider(p string) bool

func (Auths) Remove

func (a Auths) Remove(sub string) Auths

func (Auths) RemoveByProvider

func (a Auths) RemoveByProvider(p string) Auths

type BcryptPasswordEncoder

type BcryptPasswordEncoder struct{}

func (BcryptPasswordEncoder) Encode

func (BcryptPasswordEncoder) Encode(pass string) ([]byte, error)

func (BcryptPasswordEncoder) Verify

func (BcryptPasswordEncoder) Verify(s string, p []byte) (bool, error)

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

func New

func New() *Builder

func (*Builder) Auths

func (b *Builder) Auths(auths []Auth) *Builder

func (*Builder) Build

func (b *Builder) Build() (*User, error)

func (*Builder) Email

func (b *Builder) Email(email string) *Builder

func (*Builder) EncodedPassword

func (b *Builder) EncodedPassword(p EncodedPassword) *Builder

func (*Builder) ID

func (b *Builder) ID(id accountdomain.UserID) *Builder

func (*Builder) Lang

func (b *Builder) Lang(lang language.Tag) *Builder

func (*Builder) LangFrom

func (b *Builder) LangFrom(lang string) *Builder

func (*Builder) MustBuild

func (b *Builder) MustBuild() *User

func (*Builder) Name

func (b *Builder) Name(name string) *Builder

func (*Builder) NewID

func (b *Builder) NewID() *Builder

func (*Builder) ParseID

func (b *Builder) ParseID(id string) *Builder

func (*Builder) PasswordPlainText

func (b *Builder) PasswordPlainText(p string) *Builder

func (*Builder) PasswordReset

func (b *Builder) PasswordReset(pr *PasswordReset) *Builder

func (*Builder) Theme

func (b *Builder) Theme(t Theme) *Builder

func (*Builder) Verification

func (b *Builder) Verification(v *Verification) *Builder

func (*Builder) Workspace

func (b *Builder) Workspace(workspace WorkspaceID) *Builder

type EncodedPassword

type EncodedPassword []byte

func MustEncodedPassword

func MustEncodedPassword(pass string) EncodedPassword

func NewEncodedPassword

func NewEncodedPassword(pass string) (EncodedPassword, error)

func (EncodedPassword) Clone

func (p EncodedPassword) Clone() EncodedPassword

func (EncodedPassword) Verify

func (p EncodedPassword) Verify(toVerify string) (bool, error)

type ID

type ID = accountdomain.UserID

type IDList

type IDList = accountdomain.UserIDList

type List

type List []*User

type MockPasswordEncoder

type MockPasswordEncoder struct{ Mock []byte }

func (MockPasswordEncoder) Encode

func (m MockPasswordEncoder) Encode(pass string) ([]byte, error)

func (MockPasswordEncoder) Verify

func (m MockPasswordEncoder) Verify(s string, p []byte) (bool, error)

type NoopPasswordEncoder

type NoopPasswordEncoder struct{}

func (NoopPasswordEncoder) Encode

func (m NoopPasswordEncoder) Encode(pass string) ([]byte, error)

func (NoopPasswordEncoder) Verify

func (m NoopPasswordEncoder) Verify(s string, p []byte) (bool, error)

type PasswordEncoder

type PasswordEncoder interface {
	Encode(string) ([]byte, error)
	Verify(string, []byte) (bool, error)
}

type PasswordReset

type PasswordReset struct {
	Token     string
	CreatedAt time.Time
}

func NewPasswordReset

func NewPasswordReset() *PasswordReset

func PasswordResetFrom

func PasswordResetFrom(token string, createdAt time.Time) *PasswordReset

func (*PasswordReset) Clone

func (pr *PasswordReset) Clone() *PasswordReset

func (*PasswordReset) Validate

func (pr *PasswordReset) Validate(token string) bool

type Simple

type Simple struct {
	ID    ID
	Name  string
	Email string
	Host  string
}

func SimpleFrom

func SimpleFrom(u *User) *Simple

type SimpleList

type SimpleList []*Simple

type Theme

type Theme string
const (
	ThemeDefault Theme = "default"
	ThemeLight   Theme = "light"
	ThemeDark    Theme = "dark"
)

func ThemeFrom

func ThemeFrom(s string) Theme

func (Theme) Ref

func (t Theme) Ref() *Theme

func (Theme) Valid

func (t Theme) Valid() bool

type User

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

func (*User) AddAuth

func (u *User) AddAuth(a Auth) bool

func (*User) Auths

func (u *User) Auths() Auths

func (*User) ClearAuths

func (u *User) ClearAuths()

func (*User) Clone

func (u *User) Clone() *User

func (*User) ContainAuth

func (u *User) ContainAuth(a Auth) bool

func (*User) Email

func (u *User) Email() string

func (*User) GetAuthByProvider

func (u *User) GetAuthByProvider(provider string) *Auth

func (*User) HasAuthProvider

func (u *User) HasAuthProvider(p string) bool

func (*User) Host

func (u *User) Host() string

func (*User) ID

func (u *User) ID() ID

func (*User) Lang

func (u *User) Lang() language.Tag

func (*User) MatchPassword

func (u *User) MatchPassword(pass string) (bool, error)

func (*User) Name

func (u *User) Name() string

func (*User) Password

func (u *User) Password() []byte

func (*User) PasswordReset

func (u *User) PasswordReset() *PasswordReset

func (*User) RemoveAuth

func (u *User) RemoveAuth(a Auth) bool

func (*User) RemoveAuthByProvider

func (u *User) RemoveAuthByProvider(provider string) bool

func (*User) SetPassword

func (u *User) SetPassword(pass string) error

func (*User) SetPasswordReset

func (u *User) SetPasswordReset(pr *PasswordReset)

func (*User) SetVerification

func (u *User) SetVerification(v *Verification)

func (*User) Theme

func (u *User) Theme() Theme

func (*User) UpdateEmail

func (u *User) UpdateEmail(email string) error

func (*User) UpdateLang

func (u *User) UpdateLang(lang language.Tag)

func (*User) UpdateName

func (u *User) UpdateName(name string)

func (*User) UpdateTheme

func (u *User) UpdateTheme(t Theme)

func (*User) UpdateWorkspace

func (u *User) UpdateWorkspace(workspace WorkspaceID)

func (*User) Verification

func (u *User) Verification() *Verification

func (*User) WithHost

func (u *User) WithHost(host string) *User

func (*User) Workspace

func (u *User) Workspace() WorkspaceID

type Verification

type Verification struct {
	// contains filtered or unexported fields
}

func NewVerification

func NewVerification() *Verification

func VerificationFrom

func VerificationFrom(c string, e time.Time, b bool) *Verification

func (*Verification) Code

func (v *Verification) Code() string

func (*Verification) Expiration

func (v *Verification) Expiration() time.Time

func (*Verification) IsExpired

func (v *Verification) IsExpired() bool

func (*Verification) IsVerified

func (v *Verification) IsVerified() bool

func (*Verification) SetVerified

func (v *Verification) SetVerified(b bool)

type WorkspaceID

type WorkspaceID = accountdomain.WorkspaceID

type WorkspaceIDList

type WorkspaceIDList = accountdomain.WorkspaceIDList

Jump to

Keyboard shortcuts

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