Documentation ¶
Index ¶
- Constants
- Variables
- func FromEnableUserTenantContext(ctx context.Context) bool
- func GenerateOtp() (string, error)
- func NewEnableUserTenantsContext(ctx context.Context, enable ...bool) context.Context
- func NewUserMigrationTask(msg *v1.TenantCreatedEvent) (*asynq.Task, error)
- func ProfileBlob(ctx context.Context, factory blob.Factory) blob.Blob
- type DefaultEmailSender
- type EmailSender
- type EmailTokenProvider
- func (e *EmailTokenProvider) CanGenerate(ctx context.Context, user *User) error
- func (e *EmailTokenProvider) Generate(ctx context.Context, purpose TokenPurpose, user *User, duration time.Duration) (string, error)
- func (e *EmailTokenProvider) Name() string
- func (e *EmailTokenProvider) Validate(ctx context.Context, purpose TokenPurpose, token string, user *User) (bool, error)
- type LookupNormalizer
- type PasswordHasher
- type PasswordValidator
- type PasswordVerificationResult
- type PermissionSeeder
- type PhoneTokenProvider
- func (p *PhoneTokenProvider) CanGenerate(ctx context.Context, user *User) error
- func (p *PhoneTokenProvider) Generate(ctx context.Context, purpose TokenPurpose, user *User, duration time.Duration) (string, error)
- func (p *PhoneTokenProvider) Name() string
- func (p *PhoneTokenProvider) Validate(ctx context.Context, purpose TokenPurpose, token string, user *User) (bool, error)
- type RefreshToken
- type RefreshTokenRepo
- type Role
- type RoleManager
- func (r *RoleManager) Count(ctx context.Context, query *v12.ListRolesRequest) (total int64, filtered int64, err error)
- func (r *RoleManager) Create(ctx context.Context, role *Role) error
- func (r *RoleManager) Delete(ctx context.Context, id string) error
- func (r *RoleManager) FindByName(ctx context.Context, name string) (*Role, error)
- func (r *RoleManager) First(ctx context.Context, query *v12.ListRolesRequest) (*Role, error)
- func (r *RoleManager) Get(ctx context.Context, id string) (*Role, error)
- func (r *RoleManager) List(ctx context.Context, query *v12.ListRolesRequest) ([]*Role, error)
- func (r *RoleManager) Update(ctx context.Context, id string, role *Role, p query.Select) error
- type RoleRepo
- type RoleSeed
- type SignInManager
- func (s *SignInManager) CheckCanSignIn(ctx context.Context, u *User) error
- func (s *SignInManager) ExternalLoginSignInAsync(ctx context.Context, loginProvider, providerKey string, ...) error
- func (s *SignInManager) ForgetTwoFactorClient(ctx context.Context) error
- func (s *SignInManager) GetTwoFactorAuthenticationUser(ctx context.Context) (*User, error)
- func (s *SignInManager) IsSignedIn(ctx context.Context) (bool, error)
- func (s *SignInManager) IsTwoFactorClientRemembered(ctx context.Context, u *User) (bool, error)
- func (s *SignInManager) PasswordSignIn(ctx context.Context, u *User, pwd string, isPersistent bool, ...) error
- func (s *SignInManager) PasswordSignInWithEmail(ctx context.Context, email, pwd string, isPersistent bool, ...) (error, string)
- func (s *SignInManager) PasswordSignInWithPhone(ctx context.Context, phone, pwd string, isPersistent bool, ...) (error, string)
- func (s *SignInManager) PasswordSignInWithUsername(ctx context.Context, username, pwd string, isPersistent bool, ...) (error, string)
- func (s *SignInManager) RememberTwoFactorClient(ctx context.Context, u *User) error
- func (s *SignInManager) SignIn(ctx context.Context, u *User, isPersistent bool) error
- func (s *SignInManager) SignOut(ctx context.Context) error
- func (s *SignInManager) TwoFactorAuthenticatorSignIn(ctx context.Context, code string, isPersistent, rememberClient bool) error
- func (s *SignInManager) TwoFactorSignIn(ctx context.Context, provider, code string, isPersistent, rememberClient bool) error
- func (s *SignInManager) ValidateSecurityStamp(ctx context.Context, u *User, securityStamp string)
- type TenantSeedEventHandler
- type TokenPurpose
- type TwoStepTokenProvider
- type UpdateUserSetting
- type User
- type UserAddress
- type UserAddressRepo
- type UserLogin
- type UserManager
- func (um *UserManager) AddToRole(ctx context.Context, user *User, role *Role) error
- func (um *UserManager) ChangePassword(ctx context.Context, user *User, current string, newPwd string) error
- func (um *UserManager) ChangePasswordByToken(ctx context.Context, token, newPwd string) error
- func (um *UserManager) CheckDeleted(ctx context.Context, u *User) (bool, error)
- func (um *UserManager) CheckLocked(ctx context.Context, u *User) (bool, error)
- func (um *UserManager) CheckPassword(ctx context.Context, user *User, password string) error
- func (um *UserManager) Count(ctx context.Context, query *v1.UserFilter) (total int64, filtered int64, err error)
- func (um *UserManager) Create(ctx context.Context, u *User) (err error)
- func (um *UserManager) CreateWithPassword(ctx context.Context, u *User, pwd string, validate bool) (err error)
- func (um *UserManager) Delete(ctx context.Context, user *User) error
- func (um *UserManager) FindByEmail(ctx context.Context, email string) (user *User, err error)
- func (um *UserManager) FindByID(ctx context.Context, id string) (user *User, err error)
- func (um *UserManager) FindByIdentity(ctx context.Context, identity string) (user *User, err error)
- func (um *UserManager) FindByName(ctx context.Context, name string) (user *User, err error)
- func (um *UserManager) FindByPhone(ctx context.Context, phone string) (user *User, err error)
- func (um *UserManager) GenerateEmailForgetPasswordToken(ctx context.Context, user *User) (string, error)
- func (um *UserManager) GenerateForgetPasswordToken(ctx context.Context, user *User) (string, error)
- func (um *UserManager) GeneratePhoneForgetPasswordToken(ctx context.Context, user *User) (string, error)
- func (um *UserManager) GenerateRememberToken(ctx context.Context, duration time.Duration, uid uuid.UUID) (string, error)
- func (um *UserManager) GetRoles(ctx context.Context, user *User) ([]Role, error)
- func (um *UserManager) IsInTenant(ctx context.Context, uid, tenantId string) (bool, error)
- func (um *UserManager) JoinTenant(ctx context.Context, uid, tenantId string) error
- func (um *UserManager) List(ctx context.Context, query *v1.ListUsersRequest) ([]*User, error)
- func (um *UserManager) RefreshRememberToken(ctx context.Context, token string, duration time.Duration) (*User, string, error)
- func (um *UserManager) RemoveFromRole(ctx context.Context, user *User, role *Role) error
- func (um *UserManager) RemoveFromTenant(ctx context.Context, uid, tenantId string) error
- func (um *UserManager) Update(ctx context.Context, user *User, p *fieldmaskpb.FieldMask) (err error)
- func (um *UserManager) UpdatePassword(ctx context.Context, user *User, newPwd string) error
- func (um *UserManager) UpdateRoles(ctx context.Context, user *User, roles []Role) error
- func (um *UserManager) VerifyEmailForgetPasswordToken(ctx context.Context, email, token string) error
- func (um *UserManager) VerifyPhoneForgetPasswordToken(ctx context.Context, phone, token string) error
- type UserMigrationTaskHandler
- type UserRepo
- type UserRole
- type UserSeed
- type UserSetting
- type UserSettingRepo
- type UserTenant
- type UserTenantRepo
- type UserTenantStatus
- type UserToken
- type UserTokenProvider
- type UserTokenRepo
- type UserValidator
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")
)
View Source
var ProviderSet = wire.NewSet( NewUserManager, NewSignInManager, NewUserValidator, NewRoleManager, NewLookupNormalizer, NewEmailTokenProvider, NewPhoneTokenProvider, NewPasswordHasher, NewPasswordValidator, NewRoleSeed, NewUserSeed, NewPermissionSeeder, NewEmailSender, NewTenantSeedEventHandler, NewUserMigrationTaskHandler)
ProviderSet is biz providers.
Functions ¶
func GenerateOtp ¶
func NewUserMigrationTask ¶
func NewUserMigrationTask(msg *v1.TenantCreatedEvent) (*asynq.Task, error)
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 NewPermissionSeeder ¶
func NewPermissionSeeder(permission authz.PermissionManagementService, checker authz.PermissionChecker, rm *RoleManager) *PermissionSeeder
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 (*RefreshToken) Valid ¶
func (r *RefreshToken) Valid() bool
type RefreshTokenRepo ¶
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) FindByName ¶
func (*RoleManager) First ¶
func (r *RoleManager) First(ctx context.Context, query *v12.ListRolesRequest) (*Role, error)
func (*RoleManager) List ¶
func (r *RoleManager) List(ctx context.Context, query *v12.ListRolesRequest) ([]*Role, 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
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 (*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 (*SignInManager) PasswordSignIn ¶
func (*SignInManager) PasswordSignInWithEmail ¶
func (*SignInManager) PasswordSignInWithPhone ¶
func (*SignInManager) PasswordSignInWithUsername ¶
func (*SignInManager) RememberTwoFactorClient ¶
func (s *SignInManager) RememberTwoFactorClient(ctx context.Context, u *User) error
func (*SignInManager) TwoFactorAuthenticatorSignIn ¶
func (*SignInManager) TwoFactorSignIn ¶
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 ¶
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 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 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 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) ChangePassword ¶
func (*UserManager) ChangePasswordByToken ¶
func (um *UserManager) ChangePasswordByToken(ctx context.Context, token, newPwd string) error
func (*UserManager) CheckDeleted ¶
func (*UserManager) CheckLocked ¶
func (*UserManager) CheckPassword ¶
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 (*UserManager) FindByEmail ¶
func (*UserManager) FindByIdentity ¶
func (*UserManager) FindByName ¶
func (*UserManager) FindByPhone ¶
func (*UserManager) GenerateEmailForgetPasswordToken ¶
func (*UserManager) GenerateForgetPasswordToken ¶
func (*UserManager) GeneratePhoneForgetPasswordToken ¶
func (*UserManager) GenerateRememberToken ¶
func (*UserManager) IsInTenant ¶
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 (*UserManager) RemoveFromRole ¶
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 (*UserManager) UpdateRoles ¶
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 ¶
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 UserSeed ¶
type UserSeed struct {
// contains filtered or unexported fields
}
func NewUserSeed ¶
func NewUserSeed(um *UserManager, rm *RoleManager) *UserSeed
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
Source Files ¶
- biz.go
- context.go
- email_sender.go
- jobs.go
- lookup_normalizer.go
- otp.go
- password_hasher.go
- password_validator.go
- permission_seeder.go
- refresh_token.go
- role.go
- seed_contrib.go
- signin.go
- tenant_seed_event_handler.go
- user.go
- user_addr.go
- user_login.go
- user_manager.go
- user_role.go
- user_setting.go
- user_tenant.go
- user_token.go
- user_token_provider.go
- user_validator.go
Click to show internal directories.
Click to hide internal directories.