biz

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: Apache-2.0 Imports: 48 Imported by: 3

README

Biz

Documentation

Index

Constants

View Source
const (
	Admin            = "admin"
	AdminUsernameKey = "admin_username"
	AdminEmailKey    = "admin_email"
	AdminPasswordKey = "admin_password"
)
View Source
const (
	InternalLoginProvider     string = "internal"
	InternalRememberTokenName string = "remember"
)
View Source
const (
	EmailName   = "email"
	PhoneName   = "phone"
	TwoStepName = "twostep"

	ConfirmPurpose               TokenPurpose = "confirm"
	RecoverPurpose               TokenPurpose = "recover"
	RecoverChangePasswordPurpose TokenPurpose = "recover_change_password"
)
View Source
const ConnName dal.ConnName = "user"
View Source
const (
	JobTypeUserMigration = string(ConnName) + ":" + "migration"
)

Variables

View Source
var (
	ErrWriterNotFound = errors.New("writer not found")
)

ProviderSet is biz providers.

Functions

func FromEnableUserTenantContext

func FromEnableUserTenantContext(ctx context.Context) bool

func GenerateOtp

func GenerateOtp() (string, error)

func NewEnableUserTenantsContext

func NewEnableUserTenantsContext(ctx context.Context, enable ...bool) context.Context

func NewUserMigrationTask

func NewUserMigrationTask(msg *v1.TenantCreatedEvent) (*asynq.Task, error)

func ProfileBlob

func ProfileBlob(ctx context.Context, factory blob.Factory) blob.Blob

Types

type DefaultEmailSender

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

DefaultEmailSender TODO template?

func (*DefaultEmailSender) SendForgetPassword

func (d *DefaultEmailSender) SendForgetPassword(ctx context.Context, email, token string) error

func (*DefaultEmailSender) SendInviteTenant

func (d *DefaultEmailSender) SendInviteTenant(ctx context.Context, email, token string) error

type EmailSender

type EmailSender interface {
	//SendForgetPassword send forget password token
	SendForgetPassword(ctx context.Context, email, token string) error
	//SendInviteTenant send invite people into tenant
	SendInviteTenant(ctx context.Context, email, token string) error
}

func NewEmailSender

func NewEmailSender(emailer email.LazyClient, cfg *kconf.Data) EmailSender

type EmailTokenProvider

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

func NewEmailTokenProvider

func NewEmailTokenProvider(r cache.CacheInterface[string]) *EmailTokenProvider

func (*EmailTokenProvider) CanGenerate

func (e *EmailTokenProvider) CanGenerate(ctx context.Context, user *User) error

func (*EmailTokenProvider) Generate

func (e *EmailTokenProvider) Generate(ctx context.Context, purpose TokenPurpose, user *User, duration time.Duration) (string, error)

func (*EmailTokenProvider) Name

func (e *EmailTokenProvider) Name() string

func (*EmailTokenProvider) Validate

func (e *EmailTokenProvider) Validate(ctx context.Context, purpose TokenPurpose, token string, user *User) (bool, error)

type LookupNormalizer

type LookupNormalizer interface {
	// Name normalizer
	Name(name string) (string, error)
	// Email normalizer
	Email(email string) (string, error)
	// Phone normalizer
	Phone(phone string) (string, error)
}

func NewLookupNormalizer

func NewLookupNormalizer() LookupNormalizer

type PasswordHasher

type PasswordHasher interface {
	HashPassword(ctx context.Context, user *User, password string) (hash string, err error)
	VerifyHashedPassword(ctx context.Context, user *User, hashedPassword string, providedPassword string) PasswordVerificationResult
}

func NewPasswordHasher

func NewPasswordHasher() PasswordHasher

type PasswordValidator

type PasswordValidator interface {
	// Validate password
	Validate(ctx context.Context, password string) error
}

func NewPasswordValidator

func NewPasswordValidator(c *conf.UserConf) PasswordValidator

type PasswordVerificationResult

type PasswordVerificationResult int32
const (
	PasswordVerificationFail PasswordVerificationResult = iota
	PasswordVerificationSuccess
	PasswordVerificationSuccessRehashNeeded
)

type PermissionSeeder

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

func (*PermissionSeeder) Seed

func (p *PermissionSeeder) Seed(ctx context.Context, sCtx *seed.Context) error

type PhoneTokenProvider

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

func NewPhoneTokenProvider

func NewPhoneTokenProvider(r cache.CacheInterface[string]) *PhoneTokenProvider

func (*PhoneTokenProvider) CanGenerate

func (p *PhoneTokenProvider) CanGenerate(ctx context.Context, user *User) error

func (*PhoneTokenProvider) Generate

func (p *PhoneTokenProvider) Generate(ctx context.Context, purpose TokenPurpose, user *User, duration time.Duration) (string, error)

func (*PhoneTokenProvider) Name

func (p *PhoneTokenProvider) Name() string

func (*PhoneTokenProvider) Validate

func (p *PhoneTokenProvider) Validate(ctx context.Context, purpose TokenPurpose, token string, user *User) (bool, error)

type RefreshToken

type RefreshToken struct {
	Token     string    `gorm:"type:char(36);primaryKey"`
	UserId    uuid.UUID `gorm:"type:char(36);index" json:"user_id"`
	Expires   *time.Time
	Ip        string
	UserAgent string
	Used      bool
}

func NewRefreshToken

func NewRefreshToken(userId uuid.UUID, duration time.Duration, userAgent string, ip string) *RefreshToken

func (*RefreshToken) Valid

func (r *RefreshToken) Valid() bool

type RefreshTokenRepo

type RefreshTokenRepo interface {
	Create(ctx context.Context, t *RefreshToken) (err error)
	Find(ctx context.Context, token string, validOnly bool) (*RefreshToken, error)
	// Revoke refresh token
	Revoke(ctx context.Context, token string, used bool) (err error)
}

type Role

type Role struct {
	kitgorm.UIDBase
	concurrency.Version `kitgorm:"type:char(36)"`
	kitgorm.AuditedModel
	gorm2.MultiTenancy
	Name           string `json:"name" kitgorm:"index"`
	NormalizedName string `json:"normalized_name" kitgorm:"index"`
	IsPreserved    bool   `json:"is_preserved"`
}

type RoleManager

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

func NewRoleManager

func NewRoleManager(repo RoleRepo, lookupNormalizer LookupNormalizer) *RoleManager

func (*RoleManager) Count

func (r *RoleManager) Count(ctx context.Context, query *v12.ListRolesRequest) (total int64, filtered int64, err error)

func (*RoleManager) Create

func (r *RoleManager) Create(ctx context.Context, role *Role) error

func (*RoleManager) Delete

func (r *RoleManager) Delete(ctx context.Context, id string) error

func (*RoleManager) FindByName

func (r *RoleManager) FindByName(ctx context.Context, name string) (*Role, error)

func (*RoleManager) First

func (r *RoleManager) First(ctx context.Context, query *v12.ListRolesRequest) (*Role, error)

func (*RoleManager) Get

func (r *RoleManager) Get(ctx context.Context, id string) (*Role, error)

func (*RoleManager) List

func (r *RoleManager) List(ctx context.Context, query *v12.ListRolesRequest) ([]*Role, error)

func (*RoleManager) Update

func (r *RoleManager) Update(ctx context.Context, id string, role *Role, p query.Select) error

type RoleRepo

type RoleRepo interface {
	data.Repo[Role, string, v12.ListRolesRequest]
	FindByName(ctx context.Context, name string) (*Role, error)
}

RoleRepo crud role

type RoleSeed

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

func NewRoleSeed

func NewRoleSeed(roleMgr *RoleManager, permission authz.PermissionManagementService) *RoleSeed

func (*RoleSeed) Seed

func (r *RoleSeed) Seed(ctx context.Context, sCtx *seed.Context) error

type SignInManager

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

func NewSignInManager

func NewSignInManager(um *UserManager, securityCfg *conf.Security) *SignInManager

func (*SignInManager) CheckCanSignIn

func (s *SignInManager) CheckCanSignIn(ctx context.Context, u *User) error

func (*SignInManager) ExternalLoginSignInAsync

func (s *SignInManager) ExternalLoginSignInAsync(ctx context.Context, loginProvider, providerKey string, isPersistent, bypassTwoFactor bool) error

func (*SignInManager) ForgetTwoFactorClient

func (s *SignInManager) ForgetTwoFactorClient(ctx context.Context) error

func (*SignInManager) GetTwoFactorAuthenticationUser

func (s *SignInManager) GetTwoFactorAuthenticationUser(ctx context.Context) (*User, error)

func (*SignInManager) IsSignedIn

func (s *SignInManager) IsSignedIn(ctx context.Context) (bool, error)

func (*SignInManager) IsTwoFactorClientRemembered

func (s *SignInManager) IsTwoFactorClientRemembered(ctx context.Context, u *User) (bool, error)

func (*SignInManager) PasswordSignIn

func (s *SignInManager) PasswordSignIn(ctx context.Context, u *User, pwd string, isPersistent bool, tryLockoutOnFailure bool) error

func (*SignInManager) PasswordSignInWithEmail

func (s *SignInManager) PasswordSignInWithEmail(ctx context.Context, email, pwd string, isPersistent bool, tryLockoutOnFailure bool) (error, string)

func (*SignInManager) PasswordSignInWithPhone

func (s *SignInManager) PasswordSignInWithPhone(ctx context.Context, phone, pwd string, isPersistent bool, tryLockoutOnFailure bool) (error, string)

func (*SignInManager) PasswordSignInWithUsername

func (s *SignInManager) PasswordSignInWithUsername(ctx context.Context, username, pwd string, isPersistent bool, tryLockoutOnFailure bool) (error, string)

func (*SignInManager) RememberTwoFactorClient

func (s *SignInManager) RememberTwoFactorClient(ctx context.Context, u *User) error

func (*SignInManager) SignIn

func (s *SignInManager) SignIn(ctx context.Context, u *User, isPersistent bool) error

func (*SignInManager) SignOut

func (s *SignInManager) SignOut(ctx context.Context) error

func (*SignInManager) TwoFactorAuthenticatorSignIn

func (s *SignInManager) TwoFactorAuthenticatorSignIn(ctx context.Context, code string, isPersistent, rememberClient bool) error

func (*SignInManager) TwoFactorSignIn

func (s *SignInManager) TwoFactorSignIn(ctx context.Context, provider, code string, isPersistent, rememberClient bool) error

func (*SignInManager) ValidateSecurityStamp

func (s *SignInManager) ValidateSecurityStamp(ctx context.Context, u *User, securityStamp string)

type TenantSeedEventHandler

type TenantSeedEventHandler event.ConsumerHandler

func NewTenantSeedEventHandler

func NewTenantSeedEventHandler(client *asynq.Client) TenantSeedEventHandler

type TokenPurpose

type TokenPurpose string

type TwoStepTokenProvider

type TwoStepTokenProvider[T proto.Message] struct {
	// contains filtered or unexported fields
}

func NewTwoStepTokenProvider

func NewTwoStepTokenProvider[T proto.Message](creator func() T, proxy cache.CacheInterface[string]) *TwoStepTokenProvider[T]

func (*TwoStepTokenProvider[T]) Generate

func (p *TwoStepTokenProvider[T]) Generate(ctx context.Context, purpose TokenPurpose, payload T, duration time.Duration) (string, error)

func (*TwoStepTokenProvider[T]) Name

func (p *TwoStepTokenProvider[T]) Name() string

func (*TwoStepTokenProvider[T]) Retrieve

func (p *TwoStepTokenProvider[T]) Retrieve(ctx context.Context, purpose TokenPurpose, token string) (T, error)

type UpdateUserSetting

type UpdateUserSetting struct {
	Key string
	//Value new value
	Value  *data.Value
	Delete bool
}

type User

type User struct {
	gorm.UIDBase        `json:",squash"`
	concurrency.Version `gorm:"type:char(36)"`
	gorm.AuditedModel

	DeletedAt gorm2.DeletedAt `gorm:"index"`

	Name      *string `json:"name"`
	FirstName *string `json:"first_name"`
	LastName  *string `json:"last_name"`

	Username *string `json:"username" gorm:"index"`
	// NormalizedUsername uppercase normalized userName
	NormalizedUsername *string `json:"normalized_username" gorm:"index"`

	// Phone
	Phone          *string `json:"phone" gorm:"index"`
	PhoneConfirmed bool    `json:"phone_confirmed"`

	// Email
	Email *string `json:"email" gorm:"index"`
	// NormalizedEmail uppercase normalized email
	NormalizedEmail *string `json:"normalized_email" gorm:"index"`
	EmailConfirmed  bool    `json:"email_confirmed"`

	// Password hashed
	Password *string `json:"password"`

	//Security
	AccessFailedCount int        `json:"accessFailedCount"`
	LastLoginAttempt  *time.Time `json:"lastLoginAttempt"`
	LockoutEndDateUtc *time.Time `json:"lockoutEndDateUtc"`

	//2FA
	TwoFactorEnabled bool `json:"two_factor_enabled"`

	Roles []Role `gorm:"many2many:user_roles"`

	Location *string `json:"location"`
	Tags     *string `json:"tags"`

	// Avatar could be an id of asset or simple url
	Avatar   *string    `json:"avatar"`
	Birthday *time.Time `json:"birthday"`
	Gender   *string    `json:"gender"`

	Tenants []UserTenant `json:"tenants"`

	Extra data.JSONMap
	//creation tenant
	CreatedTenant *string `json:"created_tenant"`
}

type UserAddress

type UserAddress struct {
	gorm.UIDBase
	gorm.AuditedModel
	UserId   string             `json:"user_id" gorm:"index"`
	Phone    string             `json:"phone"`
	Usage    string             `json:"usage"`
	Prefer   bool               `json:"prefer"`
	Address  data.AddressEntity `json:"address" gorm:"embedded"`
	Metadata data.JSONMap       `json:"metadata"`
}

type UserAddressRepo

type UserAddressRepo interface {
	data.Repo[UserAddress, string, interface{}]
	FindByUser(ctx context.Context, userId string) ([]*UserAddress, error)
	SetPrefer(ctx context.Context, addr *UserAddress) error
}

type UserLogin

type UserLogin struct {
	UserId        uuid.UUID `gorm:"type:char(36);primaryKey" json:"user_id"`
	LoginProvider string    `gorm:"primaryKey" json:"login_provider"`
	ProviderKey   string    `gorm:"index" json:"provider_key"`
}

type UserManager

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

func NewUserManager

func NewUserManager(
	cfg *conf.UserConf,
	userRepo UserRepo,
	pwdHasher PasswordHasher,
	userValidator UserValidator,
	pwdValidator PasswordValidator,
	lookupNormalizer LookupNormalizer,
	userTokenRepo UserTokenRepo,
	refreshTokenRepo RefreshTokenRepo,
	userTenantRepo UserTenantRepo,
	emailToken *EmailTokenProvider,
	phoneToken *PhoneTokenProvider,
	strCache cache.CacheInterface[string],
	logger log.Logger) *UserManager

func (*UserManager) AddToRole

func (um *UserManager) AddToRole(ctx context.Context, user *User, role *Role) error

func (*UserManager) ChangePassword

func (um *UserManager) ChangePassword(ctx context.Context, user *User, current string, newPwd string) error

func (*UserManager) ChangePasswordByToken

func (um *UserManager) ChangePasswordByToken(ctx context.Context, token, newPwd string) error

func (*UserManager) CheckDeleted

func (um *UserManager) CheckDeleted(ctx context.Context, u *User) (bool, error)

func (*UserManager) CheckLocked

func (um *UserManager) CheckLocked(ctx context.Context, u *User) (bool, error)

func (*UserManager) CheckPassword

func (um *UserManager) CheckPassword(ctx context.Context, user *User, password string) error

func (*UserManager) Count

func (um *UserManager) Count(ctx context.Context, query *v1.UserFilter) (total int64, filtered int64, err error)

func (*UserManager) Create

func (um *UserManager) Create(ctx context.Context, u *User) (err error)

func (*UserManager) CreateWithPassword

func (um *UserManager) CreateWithPassword(ctx context.Context, u *User, pwd string, validate bool) (err error)

func (*UserManager) Delete

func (um *UserManager) Delete(ctx context.Context, user *User) error

func (*UserManager) FindByEmail

func (um *UserManager) FindByEmail(ctx context.Context, email string) (user *User, err error)

func (*UserManager) FindByID

func (um *UserManager) FindByID(ctx context.Context, id string) (user *User, err error)

func (*UserManager) FindByIdentity

func (um *UserManager) FindByIdentity(ctx context.Context, identity string) (user *User, err error)

func (*UserManager) FindByName

func (um *UserManager) FindByName(ctx context.Context, name string) (user *User, err error)

func (*UserManager) FindByPhone

func (um *UserManager) FindByPhone(ctx context.Context, phone string) (user *User, err error)

func (*UserManager) GenerateEmailForgetPasswordToken

func (um *UserManager) GenerateEmailForgetPasswordToken(ctx context.Context, user *User) (string, error)

func (*UserManager) GenerateForgetPasswordToken

func (um *UserManager) GenerateForgetPasswordToken(ctx context.Context, user *User) (string, error)

func (*UserManager) GeneratePhoneForgetPasswordToken

func (um *UserManager) GeneratePhoneForgetPasswordToken(ctx context.Context, user *User) (string, error)

func (*UserManager) GenerateRememberToken

func (um *UserManager) GenerateRememberToken(ctx context.Context, duration time.Duration, uid uuid.UUID) (string, error)

func (*UserManager) GetRoles

func (um *UserManager) GetRoles(ctx context.Context, user *User) ([]Role, error)

func (*UserManager) IsInTenant

func (um *UserManager) IsInTenant(ctx context.Context, uid, tenantId string) (bool, error)

func (*UserManager) JoinTenant

func (um *UserManager) JoinTenant(ctx context.Context, uid, tenantId string) error

JoinTenant add user into tenant. safe to call when user already in

func (*UserManager) List

func (um *UserManager) List(ctx context.Context, query *v1.ListUsersRequest) ([]*User, error)

func (*UserManager) RefreshRememberToken

func (um *UserManager) RefreshRememberToken(ctx context.Context, token string, duration time.Duration) (*User, string, error)

func (*UserManager) RemoveFromRole

func (um *UserManager) RemoveFromRole(ctx context.Context, user *User, role *Role) error

func (*UserManager) RemoveFromTenant

func (um *UserManager) RemoveFromTenant(ctx context.Context, uid, tenantId string) error

func (*UserManager) Update

func (um *UserManager) Update(ctx context.Context, user *User, p *fieldmaskpb.FieldMask) (err error)

func (*UserManager) UpdatePassword

func (um *UserManager) UpdatePassword(ctx context.Context, user *User, newPwd string) error

func (*UserManager) UpdateRoles

func (um *UserManager) UpdateRoles(ctx context.Context, user *User, roles []Role) error

func (*UserManager) VerifyEmailForgetPasswordToken

func (um *UserManager) VerifyEmailForgetPasswordToken(ctx context.Context, email, token string) error

func (*UserManager) VerifyPhoneForgetPasswordToken

func (um *UserManager) VerifyPhoneForgetPasswordToken(ctx context.Context, phone, token string) error

type UserMigrationTaskHandler

type UserMigrationTaskHandler func(ctx context.Context, t *asynq.Task) error

func NewUserMigrationTaskHandler

func NewUserMigrationTaskHandler(seeder seed.Seeder, sender event.Producer) UserMigrationTaskHandler

type UserRepo

type UserRepo interface {
	List(ctx context.Context, query *v1.ListUsersRequest) ([]*User, error)
	Count(ctx context.Context, query *v1.UserFilter) (total int64, filtered int64, err error)
	Create(ctx context.Context, user *User) error
	Update(ctx context.Context, user *User, p *fieldmaskpb.FieldMask) error
	Delete(ctx context.Context, user *User) error
	FindByID(ctx context.Context, id string) (*User, error)
	FindByName(ctx context.Context, name string) (*User, error)
	FindByPhone(ctx context.Context, phone string) (*User, error)

	AddLogin(ctx context.Context, user *User, userLogin *UserLogin) error
	RemoveLogin(ctx context.Context, user *User, loginProvider string, providerKey string) error
	ListLogin(ctx context.Context, user *User) ([]*UserLogin, error)

	FindByLogin(ctx context.Context, loginProvider string, providerKey string) (*User, error)
	FindByEmail(ctx context.Context, email string) (*User, error)
	SetToken(ctx context.Context, user *User, loginProvider string, name string, value string) error
	RemoveToken(ctx context.Context, user *User, loginProvider string, name string) error
	GetToken(ctx context.Context, user *User, loginProvider string, name string) (*string, error)
	GetRoles(ctx context.Context, user *User) ([]Role, error)
	UpdateRoles(ctx context.Context, user *User, roles []Role) error
	AddToRole(ctx context.Context, user *User, role *Role) error
	RemoveFromRole(ctx context.Context, user *User, role *Role) error
}

type UserRole

type UserRole struct {
	gorm2.UIDBase
	gorm.MultiTenancy
	UserID uuid.UUID `gorm:"type:char(36)"`
	RoleID uuid.UUID `gorm:"type:char(36)"`
}

type UserSeed

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

func NewUserSeed

func NewUserSeed(um *UserManager, rm *RoleManager) *UserSeed

func (*UserSeed) Seed

func (u *UserSeed) Seed(ctx context.Context, sCtx *seed.Context) error

type UserSetting

type UserSetting struct {
	gorm.UIDBase
	UserId string     `json:"user_id" gorm:"index"`
	Key    string     `json:"key" gorm:"index"`
	Value  data.Value `gorm:"embedded"`
}

UserSetting contains key/value pair of user settings

type UserSettingRepo

type UserSettingRepo interface {
	data.Repo[UserSetting, string, v1.GetSettingsRequest]
	FindByUser(ctx context.Context, userId string, query *v1.GetSettingsRequest) ([]*UserSetting, error)
	UpdateByUser(ctx context.Context, userId string, updateBatch []UpdateUserSetting) error
}

type UserTenant

type UserTenant struct {
	gorm2.UIDBase
	UserId    string           `gorm:"type:char(36);index" json:"user_id"`
	TenantId  *string          `json:"tenant_id" gorm:"type:char(36);index"`
	JoinTime  time.Time        `json:"join_time"`
	Status    UserTenantStatus `json:"status;index"`
	DeletedAt gg.DeletedAt     `gorm:"index"`
	Extra     data.JSONMap
}

func (*UserTenant) GetTenantId

func (u *UserTenant) GetTenantId() string

func (*UserTenant) SetTenantId

func (u *UserTenant) SetTenantId(id string) *UserTenant

type UserTenantRepo

type UserTenantRepo interface {
	JoinTenant(ctx context.Context, userId string, tenantId string, status UserTenantStatus) (*UserTenant, error)
	RemoveFromTenant(ctx context.Context, userId string, tenantId string) error
	Get(ctx context.Context, userId string, tenantId string) (*UserTenant, error)
	IsIn(ctx context.Context, userId string, tenantId string) (bool, error)
	Update(ctx context.Context, userTenant *UserTenant) error
}

type UserTenantStatus

type UserTenantStatus int32
const (
	Active   UserTenantStatus = 0
	Inactive UserTenantStatus = 1
)

func (UserTenantStatus) String

func (p UserTenantStatus) String() string

type UserToken

type UserToken struct {
	gorm.AuditedModel
	DeletedAt     gorm2.DeletedAt `gorm:"index"`
	UserId        uuid.UUID       `gorm:"type:char(36);primaryKey" json:"user_id"`
	LoginProvider string          `gorm:"primaryKey" json:"login_provider"`
	Name          string          `gorm:"primaryKey" json:"name"`
	Value         string          `json:"value"`
}

UserToken stores external login token

type UserTokenProvider

type UserTokenProvider interface {
	// Name of this provider
	Name() string
	Generate(ctx context.Context, purpose TokenPurpose, user *User, duration time.Duration) (token string, err error)
	Validate(ctx context.Context, purpose TokenPurpose, token string, user *User) (bool, error)
	CanGenerate(ctx context.Context, user *User) error
}

type UserTokenRepo

type UserTokenRepo interface {
	FindByUserIdAndLoginProvider(ctx context.Context, userId, loginProvider string) ([]*UserToken, error)
	FindByUserIdAndLoginProviderAndName(ctx context.Context, userId, loginProvider, name string) (*UserToken, error)
	DeleteByUserIdAndLoginProvider(ctx context.Context, userId, loginProvider string) error
	DeleteByUserIdAndLoginProviderAndName(ctx context.Context, userId, loginProvider, name string) error
	Create(ctx context.Context, userId, loginProvider, name, value string) (*UserToken, error)
}

type UserValidator

type UserValidator interface {
	Validate(ctx context.Context, um *UserManager, user *User) (err error)
}

UserValidator validate user before create and update

func NewUserValidator

func NewUserValidator() UserValidator

Jump to

Keyboard shortcuts

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