user

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserAlreadyJoined        = errors.New("user already joined")
	ErrCannotModifyPersonalTeam = errors.New("personal team cannot be modified")
	ErrTeamWithProjects         = errors.New("target team still has some project")
	ErrTargetUserNotInTheTeam   = errors.New("target user does not exist in the team")
)
View Source
var (
	// RoleReader is a role who can read project
	RoleReader = Role("reader")
	// RoleWriter is a role who can read and write project
	RoleWriter = Role("writer")
	// RoleOwner is a role who can have full controll of project
	RoleOwner = Role("owner")
	// ErrInvalidRole _
	ErrInvalidRole = errors.New("invalid role")
)

Functions

func Init

func Init(p InitParams) (*User, *Team, error)

Types

type Auth

type Auth struct {
	Provider string
	Sub      string
}

func AuthFromAuth0Sub

func AuthFromAuth0Sub(sub string) Auth

func (Auth) IsAuth0

func (a Auth) IsAuth0() bool

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) ID

func (b *Builder) ID(id id.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) Team

func (b *Builder) Team(team id.TeamID) *Builder

func (*Builder) Theme

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

type InitParams

type InitParams struct {
	Email    string
	Name     string
	Auth0Sub string
	Lang     *language.Tag
	Theme    *Theme
	UserID   *id.UserID
	TeamID   *id.TeamID
}

type Members

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

func CopyMembers

func CopyMembers(members *Members) *Members

func NewFixedMembers

func NewFixedMembers(u id.UserID) *Members

func NewMembers

func NewMembers() *Members

func NewMembersWith

func NewMembersWith(members map[id.UserID]Role) *Members

func (*Members) ContainsUser

func (m *Members) ContainsUser(u id.UserID) bool

func (*Members) Count

func (m *Members) Count() int

func (*Members) GetRole

func (m *Members) GetRole(u id.UserID) Role

func (*Members) IsOnlyOwner

func (m *Members) IsOnlyOwner(u id.UserID) bool

func (*Members) Join

func (m *Members) Join(u id.UserID, role Role) error

func (*Members) Leave

func (m *Members) Leave(u id.UserID) error

func (*Members) Members

func (m *Members) Members() map[id.UserID]Role

func (*Members) UpdateRole

func (m *Members) UpdateRole(u id.UserID, role Role) error

func (*Members) UsersByRole

func (m *Members) UsersByRole(role Role) []id.UserID

type Role

type Role string

Role _

func RoleFromString

func RoleFromString(r string) (Role, error)

RoleFromString _

type Team

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

func (*Team) ID

func (t *Team) ID() id.TeamID

func (*Team) IsPersonal

func (t *Team) IsPersonal() bool

func (*Team) Members

func (t *Team) Members() *Members

func (*Team) Name

func (t *Team) Name() string

func (*Team) Rename

func (t *Team) Rename(name string)

type TeamBuilder

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

TeamBuilder _

func NewTeam

func NewTeam() *TeamBuilder

NewTeam _

func (*TeamBuilder) Build

func (b *TeamBuilder) Build() (*Team, error)

Build _

func (*TeamBuilder) ID

func (b *TeamBuilder) ID(id id.TeamID) *TeamBuilder

ID _

func (*TeamBuilder) Members

func (b *TeamBuilder) Members(members map[id.UserID]Role) *TeamBuilder

Members _

func (*TeamBuilder) MustBuild

func (b *TeamBuilder) MustBuild() *Team

MustBuild _

func (*TeamBuilder) Name

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

Name _

func (*TeamBuilder) NewID

func (b *TeamBuilder) NewID() *TeamBuilder

NewID _

func (*TeamBuilder) Personal

func (b *TeamBuilder) Personal(p bool) *TeamBuilder

Personal _

type Theme

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

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() []Auth

func (*User) ClearAuths

func (u *User) ClearAuths()

func (*User) ContainAuth

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

func (*User) Email

func (u *User) Email() string

func (*User) ID

func (u *User) ID() id.UserID

func (*User) Lang

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

func (*User) Name

func (u *User) Name() string

func (*User) RemoveAuth

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

func (*User) RemoveAuthByProvider

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

func (*User) Team

func (u *User) Team() id.TeamID

func (*User) Theme

func (u *User) Theme() Theme

func (*User) UpdateEmail

func (u *User) UpdateEmail(email string)

func (*User) UpdateLang

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

func (*User) UpdateName

func (u *User) UpdateName(name string)

func (*User) UpdateTeam

func (u *User) UpdateTeam(team id.TeamID)

func (*User) UpdateTheme

func (u *User) UpdateTheme(t Theme)

Jump to

Keyboard shortcuts

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