organization

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrganizationTypePersonal OrganizationType = "personal"
	OrganizationTypeTeam                      = "team"
	OrganizationTypeBusiness                  = "business"
)

Variables

View Source
var (
	ErrDuplicateEmail = errors.New("duplicate email")
)

Functions

This section is empty.

Types

type Organization

type Organization struct {
	ID        uuid.UUID        `gorm:"type:uuid;default:gen_random_uuid()" json:"id"`
	CreatedAt time.Time        `json:"created_at"`
	UpdatedAt time.Time        `json:"updated_at"`
	DeletedAt *time.Time       `sql:"index" json:"deleted_at"`
	Name      string           `json:"name" gorm:"index:idx_name,unique;not_null"`
	Type      OrganizationType `json:"type"`
	Users     []*User          `json:"-" gorm:"many2many:organization_users;"`
	// Features for the organization
	AllowAutoCreateWorkspace bool      `json:"allow_auto_create_workspace"`
	DefaultAgentId           uuid.UUID `json:"default_agent_id"`
}

type OrganizationRepository

type OrganizationRepository interface {
	Save(org *Organization) error
	Update(org Organization)
	Delete(organizationId string)
	FindById(organizationId string) (*Organization, error)
	UserHasOrganization(userId string, organizationId string) (bool, error)
	All() ([]Organization, error)
}

func NewOrganizationRepository

func NewOrganizationRepository(db *gorm.DB) OrganizationRepository

type OrganizationRepositoryImpl

type OrganizationRepositoryImpl struct {
	Db *gorm.DB
}

func (OrganizationRepositoryImpl) All

func (OrganizationRepositoryImpl) Delete

func (o OrganizationRepositoryImpl) Delete(organizationId string)

func (OrganizationRepositoryImpl) FindById

func (o OrganizationRepositoryImpl) FindById(organizationIdOrName string) (*Organization, error)

func (OrganizationRepositoryImpl) Save

func (OrganizationRepositoryImpl) Update

func (OrganizationRepositoryImpl) UserHasOrganization added in v1.6.0

func (o OrganizationRepositoryImpl) UserHasOrganization(userId string, organizationId string) (bool, error)

type OrganizationType added in v1.6.0

type OrganizationType string

type OrganizationUser added in v1.1.0

type OrganizationUser struct {
	OrganizationID uuid.UUID `gorm:"primaryKey"`
	UserID         uuid.UUID `gorm:"primaryKey"`
	Role           string
}

type User added in v1.0.3

type User struct {
	ID        uuid.UUID  `gorm:"type:uuid;default:gen_random_uuid()" json:"id"`
	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `sql:"index" json:"deleted_at"`
	Email     string     `gorm:"index:idx_email,unique"`
	Password  string     `gorm:"column:password"`
	Active    bool       `gorm:"column:active"`

	// Confirm
	ConfirmSelector string `gorm:"column:confirm_selector"`
	ConfirmVerifier string `gorm:"column:confirm_verifier"`
	Confirmed       bool   `gorm:"column:confirmed"`

	// Lock
	AttemptCount int       `gorm:"column:attempt_count"`
	LastAttempt  time.Time `gorm:"column:last_attempt"`
	Locked       time.Time `gorm:"column:locked"`

	// Recover
	RecoverSelector    string    `gorm:"column:recover_selector"`
	RecoverVerifier    string    `gorm:"column:recover_verifier"`
	RecoverTokenExpiry time.Time `gorm:"column:recover_token_expiry"`

	// OAuth2
	OAuth2UID          string    `gorm:"column:oauth2_uid"`
	OAuth2Provider     string    `gorm:"column:oauth2_provider"`
	OAuth2AccessToken  string    `gorm:"column:oauth2_access_token"`
	OAuth2RefreshToken string    `gorm:"column:oauth2_refresh_token"`
	OAuth2Expiry       time.Time `gorm:"column:oauth2_expiry"`

	// 2fa
	TOTPSecretKey      string `gorm:"column:totp_secret_key"`
	SMSPhoneNumber     string `gorm:"column:sms_phone_number"`
	SMSSeedPhoneNumber string `gorm:"column:sms_seed_phone_number"`
	RecoveryCodes      string `gorm:"column:recovery_codes"`

	Organizations []*Organization `gorm:"many2many:organization_users;"`
}

func (User) GetArbitrary added in v1.0.3

func (u User) GetArbitrary() map[string]string

GetArbitrary from user

func (User) GetAttemptCount added in v1.0.3

func (u User) GetAttemptCount() int

GetAttemptCount from user

func (User) GetConfirmSelector added in v1.0.3

func (u User) GetConfirmSelector() string

GetConfirmSelector from user

func (User) GetConfirmVerifier added in v1.0.3

func (u User) GetConfirmVerifier() string

GetConfirmVerifier from user

func (User) GetConfirmed added in v1.0.3

func (u User) GetConfirmed() bool

GetConfirmed from user

func (User) GetEmail added in v1.0.3

func (u User) GetEmail() string

GetEmail from user

func (User) GetLastAttempt added in v1.0.3

func (u User) GetLastAttempt() time.Time

GetLastAttempt from user

func (User) GetLocked added in v1.0.3

func (u User) GetLocked() time.Time

GetLocked from user

func (User) GetOAuth2AccessToken added in v1.0.3

func (u User) GetOAuth2AccessToken() (token string)

GetOAuth2AccessToken from user

func (User) GetOAuth2Expiry added in v1.0.3

func (u User) GetOAuth2Expiry() (expiry time.Time)

GetOAuth2Expiry from user

func (User) GetOAuth2Provider added in v1.0.3

func (u User) GetOAuth2Provider() (provider string)

GetOAuth2Provider from user

func (User) GetOAuth2RefreshToken added in v1.0.3

func (u User) GetOAuth2RefreshToken() (refreshToken string)

GetOAuth2RefreshToken from user

func (User) GetOAuth2UID added in v1.0.3

func (u User) GetOAuth2UID() (uid string)

GetOAuth2UID from user

func (User) GetPID added in v1.0.3

func (u User) GetPID() string

GetPID from user

func (User) GetPassword added in v1.0.3

func (u User) GetPassword() string

GetPassword from user

func (User) GetRecoverExpiry added in v1.0.3

func (u User) GetRecoverExpiry() time.Time

GetRecoverExpiry from user

func (User) GetRecoverSelector added in v1.0.3

func (u User) GetRecoverSelector() string

GetRecoverSelector from user

func (User) GetRecoverVerifier added in v1.0.3

func (u User) GetRecoverVerifier() string

GetRecoverVerifier from user

func (User) GetRecoveryCodes added in v1.0.3

func (u User) GetRecoveryCodes() string

GetRecoveryCodes from user

func (User) GetSMSPhoneNumber added in v1.0.3

func (u User) GetSMSPhoneNumber() string

GetSMSPhoneNumber from user

func (User) GetSMSPhoneNumberSeed added in v1.0.3

func (u User) GetSMSPhoneNumberSeed() string

GetSMSPhoneNumberSeed from user

func (User) GetTOTPSecretKey added in v1.0.3

func (u User) GetTOTPSecretKey() string

GetTOTPSecretKey from user

func (User) IsOAuth2User added in v1.0.3

func (u User) IsOAuth2User() bool

IsOAuth2User returns true if the user was created with oauth2

func (*User) PutArbitrary added in v1.0.3

func (u *User) PutArbitrary(values map[string]string)

func (*User) PutAttemptCount added in v1.0.3

func (u *User) PutAttemptCount(attempts int)

PutAttemptCount into user

func (*User) PutConfirmSelector added in v1.0.3

func (u *User) PutConfirmSelector(confirmSelector string)

func (*User) PutConfirmVerifier added in v1.0.3

func (u *User) PutConfirmVerifier(confirmVerifier string)

PutConfirmVerifier into user

func (*User) PutConfirmed added in v1.0.3

func (u *User) PutConfirmed(confirmed bool)

func (*User) PutEmail added in v1.0.3

func (u *User) PutEmail(email string)

func (*User) PutLastAttempt added in v1.0.3

func (u *User) PutLastAttempt(last time.Time)

PutLastAttempt into user

func (*User) PutLocked added in v1.0.3

func (u *User) PutLocked(locked time.Time)

PutLocked into user

func (*User) PutOAuth2AccessToken added in v1.0.3

func (u *User) PutOAuth2AccessToken(token string)

PutOAuth2AccessToken into user

func (*User) PutOAuth2Expiry added in v1.0.3

func (u *User) PutOAuth2Expiry(expiry time.Time)

PutOAuth2Expiry into user

func (*User) PutOAuth2Provider added in v1.0.3

func (u *User) PutOAuth2Provider(provider string)

PutOAuth2Provider into user

func (*User) PutOAuth2RefreshToken added in v1.0.3

func (u *User) PutOAuth2RefreshToken(refreshToken string)

PutOAuth2RefreshToken into user

func (*User) PutOAuth2UID added in v1.0.3

func (u *User) PutOAuth2UID(uid string)

PutOAuth2UID into user

func (*User) PutPID added in v1.0.3

func (u *User) PutPID(pid string)

func (*User) PutPassword added in v1.0.3

func (u *User) PutPassword(password string)

func (*User) PutRecoverExpiry added in v1.0.3

func (u *User) PutRecoverExpiry(expiry time.Time)

PutRecoverExpiry into user

func (*User) PutRecoverSelector added in v1.0.3

func (u *User) PutRecoverSelector(token string)

PutRecoverSelector into user

func (*User) PutRecoverVerifier added in v1.0.3

func (u *User) PutRecoverVerifier(token string)

PutRecoverVerifier into user

func (*User) PutRecoveryCodes added in v1.0.3

func (u *User) PutRecoveryCodes(key string)

PutRecoveryCodes into user

func (*User) PutSMSPhoneNumber added in v1.0.3

func (u *User) PutSMSPhoneNumber(key string)

PutSMSPhoneNumber into user

func (*User) PutTOTPSecretKey added in v1.0.3

func (u *User) PutTOTPSecretKey(key string)

PutTOTPSecretKey into user

type UserRepository added in v1.12.0

type UserRepository interface {
	Find(userId uuid.UUID) (*User, error)
}

func NewUserRepository added in v1.12.0

func NewUserRepository(db *gorm.DB) UserRepository

type UserStore added in v1.0.3

type UserStore struct {
	Database *gorm.DB
}

func NewUserStore added in v1.0.3

func NewUserStore(db *gorm.DB) *UserStore

func (*UserStore) AddRememberToken added in v1.0.3

func (s *UserStore) AddRememberToken(_ context.Context, pid, token string) error

func (*UserStore) Create added in v1.0.3

func (s *UserStore) Create(_ context.Context, user authboss.User) error

func (*UserStore) DelRememberTokens added in v1.0.3

func (s *UserStore) DelRememberTokens(_ context.Context, pid string) error

func (*UserStore) GetUserObject added in v1.6.0

func (s *UserStore) GetUserObject(pid string) (*User, error)

func (*UserStore) Load added in v1.0.3

func (s *UserStore) Load(_ context.Context, key string) (user authboss.User, err error)

func (*UserStore) LoadByConfirmSelector added in v1.0.3

func (s *UserStore) LoadByConfirmSelector(_ context.Context, selector string) (user authboss.ConfirmableUser, err error)

func (*UserStore) LoadByRecoverSelector added in v1.0.3

func (s *UserStore) LoadByRecoverSelector(_ context.Context, selector string) (user authboss.RecoverableUser, err error)

func (*UserStore) New added in v1.0.3

func (s *UserStore) New(_ context.Context) authboss.User

func (*UserStore) NewFromOAuth2 added in v1.0.3

func (s *UserStore) NewFromOAuth2(_ context.Context, provider string, details map[string]string) (authboss.OAuth2User, error)

func (*UserStore) Save added in v1.0.3

func (s *UserStore) Save(_ context.Context, user authboss.User) error

func (*UserStore) SaveOAuth2 added in v1.0.3

func (s *UserStore) SaveOAuth2(_ context.Context, user authboss.OAuth2User) error

func (*UserStore) UseRememberToken added in v1.0.3

func (s *UserStore) UseRememberToken(_ context.Context, token string) error

Jump to

Keyboard shortcuts

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