Documentation
¶
Index ¶
- Constants
- Variables
- func FindByLogin(controller crud.CRUD, ctx op_context.Context, login string, user interface{}, ...) (bool, error)
- func FindUser[UserType User](u UserFinder[UserType], ctx op_context.Context, id string, idIsLogin ...bool) (user UserType, err error)
- type AuthUserFinderBase
- type CheckDuplicateField
- type MainFieldSetters
- type OpLogUser
- type OpLogUserHolder
- type OpLogUserI
- type SetUserFields
- type User
- type UserBase
- type UserBaseDB
- type UserBaseFields
- func (u *UserBaseFields) Display() string
- func (u *UserBaseFields) Email() string
- func (u *UserBaseFields) IsBlocked() bool
- func (u *UserBaseFields) Login() string
- func (u *UserBaseFields) Phone() string
- func (u *UserBaseFields) SetBlocked(val bool)
- func (u *UserBaseFields) SetEmail(email string)
- func (u *UserBaseFields) SetLogin(login string)
- func (u *UserBaseFields) SetPhone(phone string)
- func (u *UserBaseFields) SetUserFields(ctx op_context.Context, user User) ([]CheckDuplicateField, error)
- type UserBlocked
- type UserController
- type UserControllerBase
- func (u *UserControllerBase[UserType]) Add(ctx op_context.Context, login string, password string, ...) (UserType, error)
- func (u *UserControllerBase[UserType]) CRUD() crud.CRUD
- func (u *UserControllerBase[UserType]) Find(ctx op_context.Context, id string) (UserType, error)
- func (u *UserControllerBase[UserType]) FindByLogin(ctx op_context.Context, login string) (UserType, error)
- func (u *UserControllerBase[UserType]) FindUsers(ctx op_context.Context, filter *db.Filter) ([]UserType, int64, error)
- func (u *UserControllerBase[UserType]) MakeUser() UserType
- func (u *UserControllerBase[UserType]) OpLog(ctx op_context.Context, op string, userId string, login string)
- func (u *UserControllerBase[UserType]) SetBlocked(ctx op_context.Context, id string, blocked bool, idIsLogin ...bool) error
- func (u *UserControllerBase[UserType]) SetEmail(ctx op_context.Context, id string, email string, idIsLogin ...bool) error
- func (u *UserControllerBase[UserType]) SetOplogBuilder(builder func() OpLogUserI)
- func (u *UserControllerBase[UserType]) SetPassword(ctx op_context.Context, id string, password string, idIsLogin ...bool) error
- func (u *UserControllerBase[UserType]) SetPhone(ctx op_context.Context, id string, phone string, idIsLogin ...bool) error
- func (u *UserControllerBase[UserType]) SetUserBuilder(userBuilder func() UserType)
- func (u *UserControllerBase[UserType]) SetUserValidators(validators auth_session.UserValidators)
- type UserEmail
- type UserFieldsSetter
- type UserFieldsSetterBase
- type UserFieldsWithPassword
- type UserFinder
- type UserPhone
- type UserPlainPassword
- type Users
- type UsersBase
- type UsersValidator
- type UsersWithSession
- type UsersWithSessionBase
- type UsersWithSessionBaseConfig
Constants ¶
View Source
const ErrorCodeDuplicateEmail string = "duplicate_email"
View Source
const ErrorCodeDuplicateLogin string = "duplicate_login"
View Source
const ErrorCodeDuplicatePhone string = "duplicate_phone"
Variables ¶
View Source
var ErrorDescriptions = map[string]string{ ErrorCodeDuplicateLogin: "Login already occupied", ErrorCodeDuplicateEmail: "Email address is already in use", ErrorCodeDuplicatePhone: "Phone number is already in use", }
View Source
var ErrorHttpCodes = map[string]int{}
Functions ¶
func FindByLogin ¶
func FindUser ¶
func FindUser[UserType User](u UserFinder[UserType], ctx op_context.Context, id string, idIsLogin ...bool) (user UserType, err error)
Types ¶
type AuthUserFinderBase ¶
type AuthUserFinderBase struct { crud.WithCRUDBase // contains filtered or unexported fields }
func NewAuthUserFinder ¶
func NewAuthUserFinder(userBuilder func() User, cruds ...crud.CRUD) *AuthUserFinderBase
func (*AuthUserFinderBase) FindAuthUser ¶
func (a *AuthUserFinderBase) FindAuthUser(ctx op_context.Context, login string) (auth.User, error)
type CheckDuplicateField ¶
type MainFieldSetters ¶
type MainFieldSetters interface { SetPassword(ctx op_context.Context, id string, password string, idIsLogin ...bool) error SetPhone(ctx op_context.Context, id string, phone string, idIsLogin ...bool) error SetEmail(ctx op_context.Context, id string, email string, idIsLogin ...bool) error SetBlocked(ctx op_context.Context, id string, blocked bool, idIsLogin ...bool) error }
type OpLogUser ¶
type OpLogUser struct { oplog.OplogBase OpLogUserHolder }
type OpLogUserHolder ¶
type OpLogUserI ¶
type SetUserFields ¶
type SetUserFields[UserType interface{}] func(ctx op_context.Context, user UserType) ([]CheckDuplicateField, error)
func Email ¶
func Email[UserType User](email string, userSample ...UserType) SetUserFields[UserType]
func Phone ¶
func Phone[UserType User](phone string, userSample ...UserType) SetUserFields[UserType]
type UserBase ¶
type UserBase struct {
UserBaseDB
}
type UserBaseDB ¶
type UserBaseDB struct { common.ObjectBase UserBaseFields auth_login_phash.UserBase api.ResponseBase }
func (*UserBaseDB) ToCmd ¶
func (u *UserBaseDB) ToCmd(password string) interface{}
type UserBaseFields ¶
type UserBaseFields struct { UserPhone UserEmail UserBlocked LOGIN string `gorm:"uniqueIndex" json:"login"` }
func (*UserBaseFields) Display ¶
func (u *UserBaseFields) Display() string
func (*UserBaseFields) Email ¶
func (u *UserBaseFields) Email() string
func (*UserBaseFields) IsBlocked ¶
func (u *UserBaseFields) IsBlocked() bool
func (*UserBaseFields) Login ¶
func (u *UserBaseFields) Login() string
func (*UserBaseFields) Phone ¶
func (u *UserBaseFields) Phone() string
func (*UserBaseFields) SetBlocked ¶
func (u *UserBaseFields) SetBlocked(val bool)
func (*UserBaseFields) SetEmail ¶
func (u *UserBaseFields) SetEmail(email string)
func (*UserBaseFields) SetLogin ¶
func (u *UserBaseFields) SetLogin(login string)
func (*UserBaseFields) SetPhone ¶
func (u *UserBaseFields) SetPhone(phone string)
func (*UserBaseFields) SetUserFields ¶
func (u *UserBaseFields) SetUserFields(ctx op_context.Context, user User) ([]CheckDuplicateField, error)
type UserBlocked ¶
type UserBlocked struct {
BLOCKED bool `gorm:"index" json:"blocked"`
}
type UserController ¶
type UserController[UserType User] interface { MainFieldSetters UserFinder[UserType] Add(ctx op_context.Context, login string, password string, extraFieldsSetters ...SetUserFields[UserType]) (UserType, error) FindUsers(ctx op_context.Context, filter *db.Filter) ([]UserType, int64, error) SetUserBuilder(builder func() UserType) MakeUser() UserType SetOplogBuilder(builder func() OpLogUserI) OpLog(ctx op_context.Context, op string, userId string, login string) }
type UserControllerBase ¶
type UserControllerBase[UserType User] struct { // contains filtered or unexported fields }
func LocalUserController ¶
func LocalUserController[UserType User]() *UserControllerBase[UserType]
func (*UserControllerBase[UserType]) Add ¶
func (u *UserControllerBase[UserType]) Add(ctx op_context.Context, login string, password string, extraFieldsSetters ...SetUserFields[UserType]) (UserType, error)
func (*UserControllerBase[UserType]) CRUD ¶
func (u *UserControllerBase[UserType]) CRUD() crud.CRUD
func (*UserControllerBase[UserType]) Find ¶
func (u *UserControllerBase[UserType]) Find(ctx op_context.Context, id string) (UserType, error)
func (*UserControllerBase[UserType]) FindByLogin ¶
func (u *UserControllerBase[UserType]) FindByLogin(ctx op_context.Context, login string) (UserType, error)
func (*UserControllerBase[UserType]) FindUsers ¶
func (u *UserControllerBase[UserType]) FindUsers(ctx op_context.Context, filter *db.Filter) ([]UserType, int64, error)
func (*UserControllerBase[UserType]) MakeUser ¶
func (u *UserControllerBase[UserType]) MakeUser() UserType
func (*UserControllerBase[UserType]) OpLog ¶
func (u *UserControllerBase[UserType]) OpLog(ctx op_context.Context, op string, userId string, login string)
func (*UserControllerBase[UserType]) SetBlocked ¶
func (u *UserControllerBase[UserType]) SetBlocked(ctx op_context.Context, id string, blocked bool, idIsLogin ...bool) error
func (*UserControllerBase[UserType]) SetEmail ¶
func (u *UserControllerBase[UserType]) SetEmail(ctx op_context.Context, id string, email string, idIsLogin ...bool) error
func (*UserControllerBase[UserType]) SetOplogBuilder ¶
func (u *UserControllerBase[UserType]) SetOplogBuilder(builder func() OpLogUserI)
func (*UserControllerBase[UserType]) SetPassword ¶
func (u *UserControllerBase[UserType]) SetPassword(ctx op_context.Context, id string, password string, idIsLogin ...bool) error
func (*UserControllerBase[UserType]) SetPhone ¶
func (u *UserControllerBase[UserType]) SetPhone(ctx op_context.Context, id string, phone string, idIsLogin ...bool) error
func (*UserControllerBase[UserType]) SetUserBuilder ¶
func (u *UserControllerBase[UserType]) SetUserBuilder(userBuilder func() UserType)
func (*UserControllerBase[UserType]) SetUserValidators ¶
func (u *UserControllerBase[UserType]) SetUserValidators(validators auth_session.UserValidators)
type UserEmail ¶
type UserEmail struct {
EMAIL string `gorm:"index" json:"email,omitempty" validate:"omitempty,email" vmessage:"Invalid email format"`
}
type UserFieldsSetter ¶
type UserFieldsSetter[T User] interface { Login() string Password() string SetUserFields(ctx op_context.Context, user T) ([]CheckDuplicateField, error) }
type UserFieldsSetterBase ¶
type UserFieldsSetterBase[T User] struct { UserFieldsWithPassword }
type UserFieldsWithPassword ¶
type UserFieldsWithPassword struct { UserBaseFields UserPlainPassword }
func NewUserFieldsWihPassword ¶
func NewUserFieldsWihPassword() *UserFieldsWithPassword
func (*UserFieldsWithPassword) Password ¶
func (u *UserFieldsWithPassword) Password() string
func (*UserFieldsWithPassword) SetPassword ¶
func (u *UserFieldsWithPassword) SetPassword(password string)
type UserFinder ¶
type UserFinder[U User] interface { Find(ctx op_context.Context, id string) (U, error) FindByLogin(ctx op_context.Context, login string) (U, error) }
type UserPhone ¶
type UserPhone struct {
PHONE string `gorm:"index" json:"phone,omitempty" validate:"omitempty,phone" vmessage:"Invalid phone format"`
}
type UserPlainPassword ¶
type UserPlainPassword struct {
PlainPassword string `gorm:"-:all" json:"password"`
}
type Users ¶
type Users[UserType User] interface { auth_session.AuthUserManager UserController[UserType] }
type UsersBase ¶
type UsersBase[UserType User] struct { UsersValidator UserController[UserType] auth_session.AuthUserFinder }
func (*UsersBase[UserType]) AuthUserManager ¶
func (m *UsersBase[UserType]) AuthUserManager() auth_session.AuthUserManager
func (*UsersBase[UserType]) Construct ¶
func (u *UsersBase[UserType]) Construct(userController UserController[UserType], authUserFinder ...auth_session.AuthUserFinder)
func (*UsersBase[UserType]) SetAuthUserFinder ¶
func (u *UsersBase[UserType]) SetAuthUserFinder(authUserFinder auth_session.AuthUserFinder)
type UsersValidator ¶
func (*UsersValidator) Init ¶
func (u *UsersValidator) Init(vld validator.Validator, loginValidationRules ...string)
func (*UsersValidator) ValidateLogin ¶
func (u *UsersValidator) ValidateLogin(login string) error
func (*UsersValidator) ValidatePassword ¶
func (u *UsersValidator) ValidatePassword(password string) error
type UsersWithSession ¶
type UsersWithSession[UserType User, SessionType auth_session.Session, SessionClientType auth_session.SessionClient] interface { Users[UserType] auth_session.SessionController }
type UsersWithSessionBase ¶
type UsersWithSessionBase[UserType User, SessionType auth_session.Session, SessionClientType auth_session.SessionClient] struct { UsersBase[UserType] auth_session.SessionController }
func NewUsersWithSession ¶
func NewUsersWithSession[UserType User, SessionType auth_session.Session, SessionClientType auth_session.SessionClient]( userBuilder func() UserType, sessionBuilder func() SessionType, sessionClientBuilder func() SessionClientType, oplogBuilder func() OpLogUserI, config ...UsersWithSessionBaseConfig[UserType]) *UsersWithSessionBase[UserType, SessionType, SessionClientType]
func (*UsersWithSessionBase[UserType, SessionType, SessionClientType]) SessionManager ¶
func (m *UsersWithSessionBase[UserType, SessionType, SessionClientType]) SessionManager() auth_session.SessionController
type UsersWithSessionBaseConfig ¶
type UsersWithSessionBaseConfig[UserType User] struct { UserController UserController[UserType] SessionController auth_session.SessionController }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.